1、如何快速修改用戶中涉及多個表中某個欄位類型 1)方法一: SELECT 'alter table '||TABLE_NAME||' modify '||COLUMN_NAME||' VARCHAR2('||DATA_LENGTH||');' --要alter的sql ,T.* FROM dba_ ...
1、如何快速修改用戶中涉及多個表中某個欄位類型
1)方法一:
SELECT 'alter table '||TABLE_NAME||' modify '||COLUMN_NAME||' VARCHAR2('||DATA_LENGTH||');' --要alter的sql ,T.* FROM dba_tab_cols T WHERE OWNER = '所屬庫的用戶' AND DATA_TYPE='欄位類型' and COLUMN_NAME IN ('欄位');
2)方法二:
BEGIN FOR r IN ( select TABLE_NAME from user_tables WHERE OWNER = '所屬庫的用戶' AND DATA_TYPE='欄位類型' and COLUMN_NAME IN ('欄位') ) LOOP execute immediate 'alter table '||r.TABLE_NAME||' modify '||r.COLUMN_NAME||' VARCHAR2('||r.DATA_LENGTH||')'; END LOOP; END;
2、系統表
序號 | 表名 | 說明 |
1 |
SELECT * FROM USER_USERS; SELECT * FROM ALL_USERS; |
用戶表,可以查詢對應的用戶信息 |
2 |
SELECT * FROM USER_TABLES; SELECT * FROM USER_ALL_TABLES; SELECT * FROM USER_TAB_COMMENTS; |
數據表,可以查詢表名,表空間,表類型 |
3 |
SELECT * FROM USER_TABLESPACES; SELECT * FROM DBA_TABLESPACES; |
表空間 |
4 |
SELECT * FROM USER_TAB_COLUMNS; SELECT * FROM USER_TAB_COLS; SELECT * FROM USER_COL_COMMENTS; |
表結構,可以查詢表列詳細信息 |
5 |
SELECT * FROM USER_CONS_COLUMNS; SELECT * FROM USER_CONS_COLUMNS; |
約束 |
6 |
SELECT * FROM USER_INDEXES; SELECT * FROM USER_IND_COLUMNS; |
索引 |
7 |
SELECT * FROM USER_VIEWS; SELECT * FROM USER_MVIEWS; |
視圖 |
8 |
SELECT * FROM USER_PROCEDURES; SELECT * FROM USER_STORED_SETTINGS; |
存儲過程、存儲函數 SELECT OBJECT_NAME AS "對象名[過程名|方法名]" SELECT OBJECT_NAME AS "對象名[過程名|方法名]" |
9 |
SELECT * FROM USER_TRIGGERS; SELECT * FROM USER_TRIGGER_COLS; SELECT * FROM USER_TRIGGER_ORDERING; |
觸發器
SELECT TRIGGER_NAME AS "觸發器名"
|