oracle常用語句

2021-07-08 17:45:00 字數 911 閱讀 2923

--查詢約束

select * from user_cons_columns

--刪除約束

alter table table_test drop constraint sys_c0039695;

--新增主鍵

alter table table_test add primary key (id,fund_code)

--新增唯一約束

alter table table_test

add constraint  uk_table_test_isscode_fundcode

unique (issuer_code,fund_code);

1、只複製表結構的sql

create table b as select * from a where 1<>1

2、即複製表結構又複製表中資料的sql

create table b as select * from a

3、複製表的制定欄位的sql

create table b as select row_id,name,age from a where 1<>1//前提是row_id,name,age都是a表的列

4、複製表的指定欄位及這些指定欄位的資料的sql

create table b as select row_id,name,age from a

以上語句雖然能夠很容易的根據a表結構複製建立b表,但是a表的索引等卻複製不了,需要在b中手動建立。

5、insert into 會將查詢結果儲存到已經存在的表中

insert into t2(column1, column2, ....) select column1, column2, .... from t1

insert into branch select * from branch_bak

oracle 常用語句

oracle 產看表空間 select total.name tablespace name free space,total space free space used space,total space from select tablespace name,sum bytes 1024 102...

oracle常用語句

drop tablespace crm online space including contents and datafiles 刪除表空間 drop user wuliu01 cascade 刪除使用者 exp orcl file d dmp 匯出資料庫 imp orcl file e alen...

oracle 常用語句

oracle 常用語句 查詢表的大小 select t.owner,t.segment name,sum t.blocks 8 1024 m as s,t.segment type from dba segments t where t.owner user name group by t.owne...