查看数据库 show database;
创建数据库 Create database db_dbname;
删除数据库 Drop database db_dbname;
创建表 CREATE TABLE t_bookType(
id int primary key auto_increment,
bookTypeName varchar(20),
bookTypeDesc varchar(200)
);
创建关系表 CREATE TABLE t_book(
id int primary key auto_increment,
bookName varchar(20),
author varchar(10),
price decimal(6,2),
bookTypeId int,
constraint `fk` foreign key (`bookTypeId`) references `t_bookType` (`id`)
);
查看表结构
desc t_bookType;
show create table t_bookType;
修改表名
alter table t_book rename t_book2;
修改属性名
alter table t_book change bookName bookName2 varchar(20);
添加属性
alter table t_book add testFiled int first;
alter table t_book add testFiled int after author;
删除字段
alter table t_book drop testFiled;
删除表
drop table t_book;