MySQL创建表
show variables like ‘character_set_client’;#查询字符集
show databases;#列出所有的服务器上的数据库alter
create database if not exists test;#创建一个数据库
drop database fk;#删除数据库
show tables from test;#显示一个数据库中的表
use test;
create table tb_dept(
Id int primary key auto_increment,#部门编号 整形 主键 自增长
Name varchar(18),#部门名称
description varchar(100)#描述
);
show tables from test;
desc tb_dept;#查看表信息
show create table tb_dept;
use test;
#员工表
create table tb_emp(
id int primary key auto_increment,#auto_increment只是MySQL特有的
Name varchar(18),
sex varchar(2),
age int,
address varchar(200),
email varchar(100)
);
drop table tb_dept;
#修改列类型
#注意:不是任何情况下都可以去修改的,
#只有当字段只包含空值时才可以修改。
alter table tb_emp modify sex varchar(4);
#增加列
alter table tb_emp add tel varchar(12);
#删除列
alter table tb_emp drop tel;