现在的位置: 首页 > 综合 > 正文

Oracle开发专题之:常用操作,复制表结构等

2012年03月29日 ⁄ 综合 ⁄ 共 911字 ⁄ 字号 评论关闭

1. 复制表结构及其数据:

create table table_name_new as select * from table_name_old

 

2. 只复制表结构:

create table table_name_new as select * from table_name_old where 1=2;

 

3. 只复制表数据:

如果两个表结构一样:

insert into table_name_new select * from table_name_old

如果两个表结构不一样:

insert into table_name_new(column1,column2...) select column1,column2... from table_name_old

 

如何在Oracle中查询排序后的第一条记录

select * from (
select tb.*, rownum from table_name tb where column_name like '20080311%' order by id)
where rownum=1

 

如何查看Oracle中有哪些表

可以通过查询语句对系统表 user_tables 进行查询。

例如要列出用户表中都存在那些表,它们所使用的表空间是那个,可以用下面的语句进行查询

select table_name,tablespace_name from user_tables;

 

如何检查Oracle表空间使用情况

select * from dba_free_space

select * from dba_data_files

select b.file_id 文件ID号,b.tablespace_name 表空间名,b.bytes 字节数,
       (b.bytes-sum(nvl(a.bytes,0))) 已使用,sum(nvl(a.bytes,0)) 剩余空间,
       sum(nvl(a.bytes,0))/(b.bytes)*100 剩余百分比
from   dba_free_space a,dba_data_files b
where  a.file_id=b.file_id
group  by b.tablespace_name,b.file_id,b.bytes
order  by b.file_id

抱歉!评论已关闭.