create table Student(
StudentNo int(4) not null comment ‘学号‘,
LoginPwd varchar(20) null comment ‘‘,
StudentName varchar(20) null comment ‘学生姓名‘,
Ses tinyint(1) null comment ‘性别,取值0或1‘,
GradeId int(11) null comment ‘年级编号‘,
Phone varchar(50) not null comment ‘联系电话,允许为空,即可选输入‘,
Address varchar(255) not null comment ‘地址,允许为空,即可选为空‘,
BornDate varchar(50) null comment ‘出生时间‘,
Email varchar(50) not null comment ‘邮箱账号,允许为空,即可选输入‘,
IdentityCard varchar(18) null comment ‘身份证号‘
);
create table result(
StudentNo int(4) not null comment‘学号‘,
SubjectNo int(4) not null comment ‘课程编号‘,
ExamDate datetime not null comment ‘考试日期‘,
StudentResult int(4) not null comment ‘考试成绩‘
);
alter table Student rename as students;
alter table students add Address VARCHAR(256) not null;
alter table students MODIFY Address VARCHAR(256) null;
alter table students CHANGE Address area VARCHAR(256) null;
alter table students drop area;
drop table students;
create table students(
id int(4) primary key auto_increment,
name char(20),
age int(4),
salary double,
denger char(4)
);
insert into students (name) values(‘张三‘);
insert into students values (3,‘zhangsan‘,22,800,‘男‘);
insert into students (name,age) values(‘王三‘,20);
INSERT into students (name,age) value(‘lisi‘,29),(‘zhaoliu‘,50);
update students set salary=0 where name=‘张三‘;
update students set salary=200 where name=‘张三‘;
update students set salary=salary+500;
update students set salary=0 where name=‘王三‘;
update students set salary=0 where name=‘lisi‘;
update students set salary=0 where name=‘zhaoliu‘;
update students set salary =salary+100 where name=‘lisi‘ and name=‘zhaoliu‘;
update students set salary=salary+500,age=age+10;
update students set age=age+2 where age>=30 and age<50;
DELETE from students where age=34 or age=32;
delete from students;##
TRUNCATE table students;## 删除数据 不能删除结构 不记录日志 速度快 无法恢复 会影响自增主键的值,从1重新开始,delete 不会从1开始 默认从上次最大值+1开始
alter table students modify age not null;
update students set age=30 where name=‘lisi‘;
desc students;
select * from students;
原文:http://www.cnblogs.com/mycapple-zgs-111411/p/7660126.html