DDL

Posted zhai1997

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DDL相关的知识,希望对你有一定的参考价值。

DDL(数据库定义语言)

1、创建表

-创建表时可以添加完整性约束
create table mytable --创建表
(
id int not null,
name nchar(8) null,
sex char(2)
)

 

表中数据的数据类型:

--数值
--整型:int,smallint,bigint
--浮点:numeric(p,d) float 
--字符
--nchar(n), nvarchar(n)
--char(n),varchar(n)
--clob,text
--日期
--datetime
--二进制类型
--blob

 

2、删除表

drop table mytable   --删除

 

3、查看表的属性

sp_help mytable      --查属性

 

技术图片

4、修改表

alter table student
add nation nchar(10)              --添加属性
Alter table student
drop column nation                --删除属性
alter table student
alter column nation varchar(10)  --修改属性数据类型

 

以上是关于DDL的主要内容,如果未能解决你的问题,请参考以下文章

12C -- DDL日志

ddl是啥意思

oracle 如何看表的ddl

Oracle利用dbms_metadata.get_ddl查看DDL语句

SQL Server DDL触发器

什么是ddl dml和dcl?怎样用才最好?