CREATE TABLE `tb_emp` (
`id` int(11) NOT NULL,
`loc` varchar(60) DEFAULT NULL,
`deptId` int(11) DEFAULT NULL,
`salary` float DEFAULT NULL,
PRIMARY KEY (`id`)
) ;
1. create database test_db; (create database if not exists test_db)// 创建数据库
2. show databases ; // 显示所有数据
3. use test_db; // 指定使用数据库
4. create table tb_emp (...); (create table if no exists tb_emp (...);)// 在指定的数据库建表
5. show tables; // 显示指定数据所有表
6.desc tb_emp; (describe tb_emp) // 查看指定表的结构
7.show create table tb_emp; // 查看建表的语句
8.alter table tb_emp rename tb_emp1; // 修改数据库表名
9.alter table tb_emp modify id varchar(30); // 修改数据库表字段类型
10. alter table tb_emp change name empName varchar(25); // 修改字段名称
11. alter table tb_emp add managerId int(10); (alter table tb_emp add managerId int(10) not null; // 不能为空) ;// 添加字段
12.alter table tb_emp add num int(10) first not null; // 在表的第一列添加字段
13.alter table tb_emp drop num; // 删除表中的字段名
14.alter table tb_emp modify deptId int(11) first; // 修改字段为表中的第一个字段
15.alter table tb_emp modify deptId int(11) after id; // 修改某个字段到指定的字段之后
16.show engines; // 查看数据支持的存储引擎
17.show create table tb_emp; // 查看当前的存储引擎(ENGINE=InnoDB)
18.alter table tb_emp engine=MyISAM; // 更改表的存储引擎
19.alter table tb_emp drop primary key; // 删除主键
20.alter table tb_emp add primary key (id); // 添加主键
21.drop table if exists tb_emp; // 删除数据表
22.drop databases if exists test_db; // 删除数据库