1> 拼接建立同義詞語句
select 'create synonym ' || upper(table_name) || ' for cgtax_v_31.' || upper(table_name) || ';' from user_tables where table_name like 'cg_collect_%';
2> 拼接刪除同義詞語句
select 'drop public synonym ' || synonym_name || ';' from dba_synonyms where synonym_name like '%cg_collect_%';
3> 建立私有同義詞
4> 查詢同義詞
select * from dba_synonyms where synonym_name like '%cg_collect_%';
5> 示例:
create [or replace] [public] synonym [ schema.] 同義詞名稱 for [ schema.] object [ @dblink ];
select owner as "使用者名稱",
sum(bytes) / 1024 / 1024 / 1024 as "所有表的大小(gb)"
from dba_segments
where segment_name in (select t2.object_name
from dba_objects t2
where t2.object_type = 'table')
group by owner
1> alter database datafile 'c:\sde.dbf' autoextend on next 100m maxsize unlimited;
2> alter tablespace users autoextend on next 100m maxsize unlimited;
3> alter database datafile 'd:\dsinstall\oracle\oradata\orcl\users02.dbf' autoextend on next 100m maxsize unlimited;
4> alter tablespace users add datafile 'd:\dsinstall\oracle\oradata\orcl\users03.dbf' size 1024m autoextend on next 100m maxsize unlimited;
select upper(f.tablespace_name)"表空間名",
d.tot_grootte_mb "表空間大小(m)",
d.tot_grootte_mb-f.total_bytes "已使用空間(m)",
to_char(round((d.tot_grootte_mb-f.total_bytes)/d.tot_grootte_mb*100,2),'990.99')||'%'"使用比",
f.total_bytes "空閒空間(m)",
f.max_bytes "最大塊(m)"
from(select tablespace_name,
round(sum(bytes)/(1024*1024),2)total_bytes,
round(max(bytes)/(1024*1024),2)max_bytes
from sys.dba_free_space
group by tablespace_name)f,
(select dd.tablespace_name,
round(sum(dd.bytes)/(1024*1024),2)tot_grootte_mb
from sys.dba_data_files dd
group by dd.tablespace_name)d
where d.tablespace_name=f.tablespace_name
order by 1;
select a.file#,
a.name,
a.bytes / 1024 / 1024 currentmb,
ceil(hwm * a.block_size) / 1024 / 1024 resizeto,
(a.bytes - hwm * a.block_size) / 1024 / 1024 releasemb,
'alter database datafile ''' || a.name || ''' resize ' ||
ceil(hwm * a.block_size) / 1024 / 1024 || 'm;' resizecmd
from v$datafile a,
(select file_id, max(block_id + blocks - 1) hwm
from dba_extents
group by file_id) b
where a.file# = b.file_id(+)
and (a.bytes - hwm * a.block_size) >0
and rownum < 10
Oracle學習筆記(2)
pl sql pl sql優點 1 良好的互動性 2 無法替代的觸發器功能 3 自動優化 尤其針對余大迴圈,pl sql效能更優 pl sql塊的結構 declare 宣告部分 在此宣告pl sql用到的變數,型別及游標,以及區域性的儲存過程和函式 begin 執行部分 過程及sql 語句 即程式的...
oracle 學習筆記 2
oracle 表管理 表名必須以字母開頭,不能超過30個字元,不用保留字,只能使用如下字元a z,a z,0 9,等。oracle資料型別 字元型char 定長 最大2000字元,效率高,查詢速度很快。char 10 不足10的用空格補齊。varchar2 變長 最大4000字元 clob 字元型大...
Oracle 學習筆記2
如何檢視一台機器的windows server 2003 系統是32位還是64位 開始 執行 cmd systeminfo 檢視資料庫是否處於force logging 模式?select force logging from v database 查詢oracle server端 的字符集?sel...