【create, drop database and alter/modify the traits of table column】
发布时间:2023年12月21日
create, drop database and alter/modify the traits of table column
mysql>createdatabase Dec21th2023_a DEFAULTCHARACTERSET utf8;
Query OK,1row affected (0.00 sec)
mysql>showdatabases;+--------------------+|Database|+--------------------+| information_schema || Dec21th2023_a || mysql || pbootcms || performance_schema || sys |+--------------------+6rowsinset(0.00 sec)
mysql>dropdatabase Dec21th2023_a;
Query OK,0rows affected (0.01 sec)
mysql>showdatabases;+--------------------+|Database|+--------------------+| information_schema || mysql || pbootcms || performance_schema || sys |+--------------------+5rowsinset(0.00 sec)
mysql>createdatabase Dec21th2023_a DEFAULTCHARACTERSET utf8;
Query OK,1row 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||+---------------+-------------+------+-----+---------+-------+3rowsinset(0.00 sec)
mysql>ALTERTABLE subject COLUMN subject_id intPRIMARYKEYAUTO_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 touse near 'COLUMN subject_id int PRIMARY KEY AUTO_INCREMENT' at line 1
mysql>ALTERTABLE subject MODIFYCOLUMN subject_id intPRIMARYKEYAUTO_INCREMENT;