Oracle的常用知識技巧

才智咖 人氣:6.11K

你是不是準備考試Oracle認證,那麼你知道Oracle考試中的常用知識技巧嗎?下面跟本站小編一起來看看吧!

Oracle的常用知識技巧

對資料表要進行備份可以在同一表空間裡新建一張表:CREATE TABLE T_BAK AS SELECT * FROM T

如果要對某些表或檢視建立同義詞可以通過語句執行:

Oracle程式碼

select ‘create or replace public synonym ’||table_name||‘ for user.’||table_name||‘;’ from user_tables

select ‘create or replace public synonym ’||view_name||‘ for user.’||view_name||‘;’ from user_views

select ‘create or replace public synonym ’||sequence_name||‘ for user.’||sequence_name||‘;’ from user_sequences

同樣可以利用這個語句執行刪除:

Oracle程式碼

select ‘drop table ’||table_name||‘;’ from user_tables

where table_name like ‘%T%’

select ‘drop PUBLIC SYNONYM ’||table_name||‘;’ from user_tables

where table_name like ‘%T%’

要匯出使用者下的表的方法:

Oracle程式碼

exp user/password@Database file=“D:” log=“D:”

要匯入使用者下的某些表的方法:

Oracle程式碼

imp user/password@Database file=D:ackuporacle fromuser = user1 tables=t_XXX touser=user

新建sequence

你首先要有CREATE SEQUENCE或者CREATE ANY SEQUENCE許可權。

Oracle程式碼

CREATE SEQUENCE emp_sequence

INCREMENT BY 1 -- 每次加幾個

START WITH 1 -- 從1開始計數

NOMAXvalue -- 不設定最大值

NOCYCLE -- 一直累加,不迴圈

CACHE 10; --設定快取cache個序列,如果系統down掉了或者其它情況將會導致序列不連續,也可以設定為---------NOCACHE

更改表索引的表空間:

Oracle程式碼

select ‘alter index ’||index_name||‘ rebuild tablespace T_INDEX;’

from user_indexes

where owner=‘×××’ and

table_name in (‘×××’, ‘×××’);

TAGS:Oracle