创建数据库
create database test_db;
show create database test_db\G;
删除数据库
drop database test_db;
show engines;查看所有引擎
show variables like 'storage_engine';查看默认存储引擎
创建表
create table t_dept( id int(11) primary key, name varchar(25) not null, location varchar(50));
create table t_emp( id int(11) primary key auto_increment, name varchar(25), deptid int(11), salary float, constraint fk_emp_dept foreign key(deptid) references t_dept(id));
查看表
desc t_emp;
show create table t_emp\G;
alter table t_emp2 rename t_emp1;
alter table t_emp1 modify name varchar(30);
alter table t_emp1 change name names varchar(25);
alter table t_emp1 add worktime date default now() after deptid;
alter table t_emp1 drop worktimess;
alter table t_emp1 modify salary float after names;
alter table t_emp1 engine=MyISAM;
alter table t_emp1 drop forengn key fk_emp_dept1;
drop table if exists t_emp1;