Oracle學習記錄整理筆記3 預設的管理表

2021-07-15 09:49:04 字數 2600 閱讀 8400

這一項比較雜,我也就不分開寫了!

--查詢表空間

select tablespace_name, file_id, file_name,

round(bytes/(1024*1024),0) total_space

from dba_data_files

order by tablespace_name;

--更改表空間

alter database datafile 'd:\run\oracle\product\oradata\testdev\ts_data.dbf'

resize 2048m;

--dir目錄的清單,建立了dir的可以直接在需要寫目錄的地方替換為dir

select * from dba_directories

select count(*) from v$process; -- 當前連線數

select value from v$parameter where name='processes'; --最大連線數

--查詢資料庫版本

select * from v$version

-- 匯出序列

select ' create sequence '||sequence_name|| ' increment by '||

increment_by ||' start with '||last_number||' maxvalue '||

max_value ||' cache '||cache_size||' order nocycle ;'

from user_sequences;

--通過表名增加seq_來生成序列

select ' create sequence '||'seq_'||table_name|| ' increment by 1 start with 1000 maxvalue 9999999999999999999999999999 cache 20 order nocycle ;'

from user_tables;

--刪除所有外來鍵約束 

select 'alter table '||table_name||' drop constraint '||constraint_name||';' from user_constraints where constraint_type='r' 

--禁用所有外來鍵約束

select 'alter table '||table_name||' disable constraint '||constraint_name||';' from user_constraints where constraint_type='r' 

--啟用所有外來鍵約束

select 'alter table '||table_name||' enable constraint '||constraint_name||';' from user_constraints where constraint_type='r' 

--sequences

select * from user_sequences;

--主鍵

select * from user_indexes where uniqueness='nonunique';

--查詢某個表的所有列

select column_name from user_tab_columns where table_name = 'c_xs0702'

只是生成索引的,自己都看了好久user_ind_columns是列級索引,因為外關聯,可能會重複
/**

create index idx_role_user on user_role

(role_id)

logging

noparallel;

**/--select 'create index '||ui.index_name||' on '||ui.table_name||' ('||uc.column_name||') logging noparallel;'

select ui.index_name,count(1)

--select ui.index_name,ui.table_name,uc.column_name

from user_indexes ui,user_ind_columns uc

where ui.index_name =uc.index_name

and ui.table_name = uc.table_name

and ui.uniqueness='nonunique'

group by ui.index_name

--and ui.index_name in ('index_w_history','index_deduct_to_wlog','idx_sydw_org_mov','w_log_pm_unit','review_type_year','index_w_log')

貌似還不少,回頭慢慢理一下了。

Oracle學習記錄整理筆記2 使用者管理

使用者管理為啥是第二個呢,奇怪了 建立使用者 create user jwb01 identified by jwb01 給予session grant create session to jwb01 授權資源 grant resource to jwb01 給建立許可權 選項可以有管理許可權cre...

oracle學習筆記3

1.子查詢 select ename,sal,deptno from emp where sal in select max sal from emp group by deptno 求在不同部門薪水最高的雇員的資訊 錯誤!因為查詢的結果是工資是在所有部門下的最高工資範圍中,就是說存在一種結果 同一...

oracle學習筆記 3

生成表 臨時表,存在於事務範圍或會話範圍,供全體使用者使用 create global temporary table temp emp empno number,ename varchar2 10 create table emp copy as select from emp where dep...