常用DDL语句
轉自:http://www.ej38.com/showinfo/sql-Oracle-112851.html
?
oracle操作語句:
1.創建表
create table 表名(
?列名1 類型,
?列名2 類型
);
2.修改類屬性
alter table 表名 modify(列名 類型);
3.添加列
alter table 表名 add(列名 類型);
4.添加主鍵約束和非空約束
alter table 表名 add constraint pk_表名 primary key(列名);
alter table 表名 modify(列名 not null);
5.刪除主鍵約束
alter table 表名 drop primary key;
alter table 表名 drop constraint pk_表名;
6.失效約束
alter table 表名 disable primary key;
alter table 表名 disable constraint pk_表名;
7.有效約束
alter table 表名 enable primary key;
alter table 表名 enable constraint pk_表名;
8.刪除列
alter table 表名 drop column 列名;
9.設置某列不可用,然后刪除
alter table 表名 set unused(列名);
alter table 表名 drop unused columns;
10.修改表名
rename 表名1 to 表名2
alter 表名1 rename to 表名2;
???? 修改列明
ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name;
11.截斷表
truncate table 表名;
12.截斷表保留行空間
truncate table 表名 resue storage;
13.查看表結構
desc table 表名;
14.刪除表
drop table 表名;
15.插入記錄
例:insert into 表名 values(內容1,內容2,內容3,內容4);
16.帶參數對話方式插入行
例:insert into 表名 values(&列名1,&列名2);
? insert into 表名 values(內容1,內容2);
17.插入某幾列記錄
insert into 表名(列名1,列名2) values(內容1,內容2);
18.為列插入空值(其列不能為not null)
insert into 表名 values(內容1,null,null);
19.創建表(包括主鍵及外鍵設置)方法一
create table 表名(
? 列名1 類型
? constraint pk_表名 primary key,
? 列名2 類型 not null,
? 列名3 類型?
? constraint fk_表名 reference 表名(列名),
? 列名3 類型
? constraint ......
總結
- 上一篇: 优化数据库大幅度提高Oracle的性能
- 下一篇: 抗日战争解读八年侵华战争中国死了多少日本