1.查询当前连接下的数据库
show databases;
2.创建新的数据库
create database [if not exists] java03 [charset utf8];
//create database java03;
3.删除一个数据库
drop database [if exists] java03;
4.设定编码集
alter database java03 character set utf8;
5.进入java03数据库
use java03;
6.展示当前数据库 所有表格
show tables;
7.建表
create table 表名(
列名 1 类型,
列名2 类型,
...
);
8.打印表格的创建语句
show create table 表名
//show create table class;
9.查看表结构
desc 表名;
//desc class;
10.删除表
drop table 表名;
11.添加列
alter table 表名 add (列名1 类型,列名2 类型,... );
12修改列名类型
alter table 表名 modify 列名 类型;
//alter table student modify classid char ;
将 student 表中的classid列类型变为char类型
13修改列名
alter table 表名 change 旧列名 新列名 类型;
//alter table student change classid class char ;
将student表中的classid这一列的列名改为class
14.删除列
alter table 表名 drop 列名 ;
//alter table student drop class ;
删除student 表中的class这一列
15.修改表名
alter table 旧表名 rename 新表名 ;
//alter table student rename s1 ;
将student表的表名变为s1
以上就是ddl语句的实例详解的详细内容。
