3.0 oracle创建/复制表

时间:2021-09-22
本文章向大家介绍3.0 oracle创建/复制表,主要包括3.0 oracle创建/复制表使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

createtableWSGW_LOG

(
c_id VARCHAR2(32) not null,
service_code VARCHAR2(32),
mobile VARCHAR2(512),
request_xml VARCHAR2(4000),
response_xml VARCHAR2(4000),
content CLOB,
update_time DATE
)
alter table WSGW_LOG add primary key (C_ID)
-- alter table WSGW_LOG add constraint idCode primary key(c_id,service_code) //联合主键写法
 
comment on columnWSGW_LOG.c_idis '日志编号'; //注释
ddl操作语句:
alter table business_apply add IsAutoFinish varchar2(2);
alter table business_apply drop column IsAutoFinish;
alter table acct_transaction modify relativeobjectno varchar2(200);
 
--ddl 删除字段
alter table d_seal drop column rela_equip_categ;
alter table d_seal drop column rela_id;
 
高级创建:复制表:复制数据!
--新建表:
create table table1( id varchar(300) primary key, name varchar(200) not null);
--修改表名: alter table table1 rename to table2;
 
--表数据复制:
insert into table1 (select * from table2);
sql 复制 --两表结构一致的情况
insert into pub_REE_DATA select *from r_data where cons_no=?
 
--复制表结构: create table table1 select * from table2 where 1>1;
 
--复制表结构和数据:create table table1 select * from table2;
create table ACCT_DEPOSIT_ACCOUNTS_20180209 as select *From ACCT_DEPOSIT_ACCOUNTS;
 
--复制指定字段: create table table1 as select id, name from table2 where 1>1;
--条件查询: select id,name (case gender when 0 then '' when 1 then ‘女’ end ) gender from table1
 
 
 
 
 
--注意表空间位置和大小以及用户密码按照现场实际情况修改
--1、创建易作业业务用户表空间
CREATE TABLESPACE TS_YIZYINFO
LOGGING DATAFILE '/home/oracle/app/oradata/ydzydb/TS_YIZYINFO.dbf' SIZE 5120M
AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
 
--2、创建易作业用户
-- Create the user
create user YIZY
default tablespace TS_YIZYINFO
identified by "Yzy.10769";
grant connect to YIZY;
grant imp_full_database to YIZY;
grant resource to YIZY;
grant create materialized view to YIZY;
grant create session to YIZY;
grant create synonym to YIZY;
grant create trigger to YIZY;
grant create view to YIZY;
grant global query rewrite to YIZY;
grant query rewrite to YIZY;
grant create job to YIZY;
grant unlimited tablespace to YIZY;
 
 
 
-----MMWP_GROUP用户下相关表赋权给YIZY用户--------
grant all on A_I_CODE to YIZY;
grant all on A_I_CODE_SORT to YIZY;
grant all on A_MESSAGE to YIZY;
grant all on A_WORK_CUR to YIZY;
grant all on BOX_RECORD_INFO to YIZY;
grant all on K_DIM_RELA to YIZY;

原文地址:https://www.cnblogs.com/zl-programmer/p/15320961.html