文件名称:数据库数据库数据库数据库
文件大小:2KB
文件格式:TXT
更新时间:2022-11-15 08:28:07
SJK
创建数据表 mysql> CREATE TABLE student_tb -> ( -> id INT(20), -> name CHAR(20), -> age INT(2), -> sex CHAR(14) -> ); 查看数据表 mysql> SHOW TABLES; +------------------+ | Tables_in_itcost | +------------------+ | student_tb | | tb_grade | +------------------+ 2 rows in set 查看创建的数据表 (mysql> DESC student_tb;) mysql> SHOW CREATE TABLE student_tb; +------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | student_tb | CREATE TABLE `student_tb` ( `id` int(20) DEFAULT NULL, `name` char(20) DEFAULT NULL, `age` int(2) DEFAULT NULL, `sex` char(14) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 | +------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set 修改数据表名 mysql> ALTER TABLE student_tb RENAME student_tb_1923; 修改字段名(+数据类型) mysql> ALTER TABLE student_tb_1923 CHANGE id student_id INT(20); 添加字段名 ALTER TABLE student_tb_1923 ADD id INT(20) FIRST; 移动字段名 ALTER TABLE student_tb_1923 MODIFY age INT(2) AFTER student_id;