1. 程式人生 > >oracle資料庫資料定義語言DDL

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),

drop column Ssex

);

3.使用drop刪除表

drop table student;