【create, drop database and alter/modify the traits of table column】

create, drop database and alter/modify the traits of table column

mysql> create database Dec21th2023_a  DEFAULT CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| Dec21th2023_a      |
| mysql              |
| pbootcms           |
| performance_schema |
| sys                |
+--------------------+
6 rows in set (0.00 sec)

mysql> drop database Dec21th2023_a;
Query OK, 0 rows affected (0.01 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| pbootcms           |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

mysql> create database Dec21th2023_a  DEFAULT CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)

mysql> describe subject;
+---------------+-------------+------+-----+---------+-------+
| Field         | Type        | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| subject_id    | int(11)     | YES  |     | NULL    |       |
| subject_name  | varchar(20) | YES  |     | NULL    |       |
| subject_hours | int(11)     | YES  |     | NULL    |       |
+---------------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

mysql> ALTER TABLE subject COLUMN subject_id int PRIMARY KEY AUTO_INCREMENT;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COLUMN subject_id int PRIMARY KEY AUTO_INCREMENT' at line 1
mysql> ALTER TABLE subject MODIFY COLUMN subject_id int PRIMARY KEY AUTO_INCREMENT;

你可能感兴趣的:(DataBase,-,SQL,数据库,adb,android)