1、数据库
(1创建数据库:create database stusys;
(2)查看数据库:show databases;
(3) 选择数据库:use stusys;
(4)修改数据库:alter database stusys
default character set gb2312
default collate gb2312_chinese_ci;
(5)删除数据库:drop database stusys;
2、表
(1)创建表:create table student
(
sno char(6) not null primary key,
sname char(8) not null,
ssex char(2) not null default '男',
sbirsday date not null,
speciality char(12) null,
tc tinyint null
);
(2)查看表:use stusys;
show tables;
(3)查看表的基本结构:show columns from student;或desc student;
(4)查看表的详细结构:show create table student\G
(5)修改表-添加列:alter table stusys.student1
add column sid int not null unique auto_increment first;
(6)修改表-修改列:alter table stusys,student1
change column sbirthsday sage tinyint default 18;
(7)修改表-删除列:alter table stusys.student
drop column sid;
(8) 重命名表:alter table stusys.student1
rename to stusys.student2;或rename stusys.student2 to stusys.student3;
(9)删除表:drop table;
(10)查看存储引擎:show engines;