oracle数据库数据定义语言DDL

1.使用create创建表

1)表中字段常用的数据类型:1:vachar2(可变长度的字符串)、char(定长的字符串)、nvachar2(unicode字符集的可变长度的字符串)、nchar(unicode的定长的字符串)、long(变长的字符串)2:数字型:number(p,s)最大精度38位的十进制、float(126位数据的二进制)3:日期型:date、timestamp

代码:

create table student(

Sno  char(10) primary key,

Sname char(20) unique,

Ssex char(2),

Sdept char(40)

);

其中需要注意的是主键的表示是primary key,外键foreign  key SNO references Course(Sno)

2.使用alter修改表

alter table student(

add Sage smallint,

modify Sname char(40),

扫描二维码关注公众号,回复: 3913681 查看本文章

drop column Ssex

);

3.使用drop删除表

drop table student;

猜你喜欢

转载自blog.csdn.net/weixin_42329945/article/details/83347747