mysql> create table student(
-> no varchar(20) primary key,
-> name varchar(20) not null,
-> sex varchar(20) not null,
-> birthday datetime not null unique key,
-> class varchar(20) not null);
Query OK, 0 rows affected (0.01 sec)
mysql> insert student(no,name,sex,birthday,class) values('105','张三','女','1987-9-2 00:00:00','123');
Query OK, 1 row affected (0.00 sec)
【切记:如果再插入是无法识别中文则——sex names gbk;也是编码的问题】
mysql> select * from student order by class desc;
mysql> select distinct class from student;
mysql> select no,name,sex from student;
mysql> select name from student where name not like '小%';
mysql> alter table student add degree int not null after class;
、
mysql> update student set degree=degree+65 where no='105';
mysql> update student set degree=degree+1;
mysql> select * from student where degree=99 or degree between 60 and 70;
mysql> select * from student where class='123' or sex='女';
mysql> select name from student where class='123' or sex='女';
mysql> select * from student order by degree;
mysql> select COUNT(*),COUNT(DISTINCT class) from student where sex='女';
mysql> select distinct no from student where degree>85;