--create table student; 创建了一个名为student 表;
数据表中数据三大类型:数字、字符串、日期;
--int float double tinyInt smallInt bigInt
int(10)指的是10位的整数;
float(5,2)指的是一共5位,其中2位是小数;
--char,varchar
char(5): 'ab' 从char(5)里取出来的就是3个空格加上ab;
varchar(5) :'ab'从varchar(5)里取出来的就是'ab';
--date datetime;
--create table student( id varchar(5) primary key,name varchar(10) not null,birthday date,sex char(2) check(sex in('男','女')),goal int check(goal>=0 and goal<=100) );
--descrirbe student; 描述显示表talbe 的结构;
添加一个列:alert table student add teacher varchar(10);
删除一个列:alert table student drop teacher;
修改一个列的数据类型:alert table student modify teacher varchar(20);
修改一个列的约束:alert table student modify teacher varchar(20) not null;
修改一个列的名字:alert table student change teacher t1 varchar(20);
网友评论