show variables like ‘character_set_client’;#查询字符集
2 show databases;#列出所有的服务器上的数据库alter
3 create database if not exists test;#创建一个数据库
4 drop database fk;#删除数据库
5 show tables from test;#显示一个数据库中的表
6 use test;
7
8 create table tb_dept(
9 Id int primary key auto_increment,#部门编号 整形 主键 自增长
10 Name varchar(18),#部门名称
11 description varchar(100)#描述
12 );
13
14 show tables from test;
15
16 desc tb_dept;#查看表信息
17
18 show create table tb_dept;
19
20 use test;
21 #员工表
22 create table tb_emp(
23 id int primary key auto_increment,#auto_increment只是MySQL特有的
24 Name varchar(18),
25 sex varchar(2),
26 age int,
27 address varchar(200),
28 email varchar(100)
29 );
30
31 drop table tb_dept;
32 #修改列类型
33 #注意:不是任何情况下都可以去修改的,
34 #只有当字段只包含空值时才可以修改。
35 alter table tb_emp modify sex varchar(4);
Mysql建表语句
最新推荐文章于 2024-04-09 23:17:56 发布