1.创建一个名为mydb的数据库
mysql> show database mydb;
查询
mysql> show database mydb;
2.创建一个学生信息表
mysql> create table mydb.student_informtion(
-> student_id int UNSIGNED NOT NULL PRIMARY KEY, //非空(不允许为空),为这个表的主键 --- 学号
-> student_name varchar(64) NOT NULL, //姓名
-> student_gender char(1) NOT NULL, //性别
-> student_age INT UNSIGNED NOT NULL, //年龄
-> student_native TEXT(3), //籍贯
-> student_face TINYTEXT //面貌
-> )
-> ENGINE=INNODB; //指定储存引擎为INNODB
Query OK, 0 rows affected (0.01 sec)
查询所建的表
mysql> show tables from mydb;
查询表结构内容
mysql>desc student_informtion;
3. 修改列类型
mysql> alter table
-> student_informtion modify
-> student_gender varchar(1);
mysql>desc student_informtion;
4.增加行
mysql> alter table
-> student_informtion add
-> student_home char(1);
mysql>desc student_informtion;
5.删除行
mysql> alter table student_informtion
-> drop
-> student_home;
mysql>desc student_informtion;
6.更改列名
mysql> alter table student_informtion
-> change
-> student_id
-> student_id1
-> int;
mysql>desc student_informtion;
7.更改表名
mysql> alter table student_informtion
-> rename
-> student_info;
mysql> desc student_info;
mysql> show tables from mydb;