如何在Oracle中复制表结构和表数据
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;
或者:
create table table_name_new like table_name_old
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中存储过程或者视图等对象创建时,如果涉及到另外一个用户的表,即使你已经grant dba了,也不行,必须显式地赋予查询权限。否则,你会发现在pl/sql中可以执行语句,但是一旦放到create 中就告诉你权限不足。
grant select any table to user ......
DBA们经常会遇到一个这样令人头疼的问题:不知道谁在Oracle上创建了一个用户,创建时,没有给这个用户指定默认表空间,所以这个用户就会采用默认的表空间——system表空间。导致系统表空间迅速被用户数据占满,直至宕机。
在10G中,DBA有办法避免这种问题了——在线指定系统默认表空间:
ALTER DAT ......
常用SQL查询:
1、查看表空间的名称及大小
select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name;
2、查看表空间物理文件的名称及大小
select t ......
INSERT INTO hydlsrs@remote_zzh
SELECT * from hydlsrs where zzh='2'
hydlsrs为表名 @remote_zzh为库名
select * from hydlsrs为另1库中表名,
不同库中相同表结构,可以跨库插入。用于
2地倒入表内容。 ......