oracle经常使用sql

1. 查询表的结构oop

select * from user_tab_columns where Table_Name='用户表'; 

select * from all_tab_columns where Table_Name='用户表'; 

select * from dba_tab_columns where Table_Name='用户表';it

2. 获取表io

select table_name from user_tables; //当前用户的表       

select table_name from all_tables; //全部用户的表   

select table_name from dba_tables; //包括系统表 

select table_name from dba_tables where owner='用户名'table

3. 查询当前库中以Unit开头的表的全部列select

select table_name,COLUMN_Name
from user_tab_columns
where table_name in
(select table_name from user_tables where table_name like 'Unit%')exception

4.批量重命名im

begin
for c in (select table_name tn from user_tables where table_name <> upper(table_name)) loop
begin
execute immediate 'alter table "'||c.tn||'" rename to '||c.tn;
exception
when others then
dbms_output.put_line(c.tn||'已存在');
end;
end loop;
end;命名

相关文章
相关标签/搜索