1、数据库导入导出DMP文件(一般要以adm账号来执行)
a)从正式库导出数据:
exp sw_adm/swadm123@cwdevdb owner=sw_adm
file=E:\20121217cwdevdb.dmp log=E:\20121217cwdevdb.log
exp sw_adm/swadm@cwdb owner=sw_adm file=D:\sw20121220.dmp
log=D:\sw20121220.log
b)把正式数据导入测试库
imp sw_adm/swadm123abc@cwdevdb fromuser=sw_app touser=sw_app
file=20121217cwdevdb.dmp ignore=y destroy=y
buffer=409600 feedback=10000 statistics=none
log=20121217cwdevdb_i.log
ps:可以在CMD命令行下执行
c) 导出空表
oracle11g的新特性,数据条数是0时不分配segment,所以就不能被导出。
设置deferred_segment_creation 参数为FALSE后,无论是空表还是非空表,都分配segment。
alter system set deferred_segment_creation=false;
先查询一下哪些表是空的,生成修改语句
select 'alter table ' || table_name || ' allocate
extent;' as sql from all_tables where num_rows = 0 and
OWNER='SW_ADM' ;
然后执行语句,即可导出空表:
exp sw_adm/xxx@CWDEVDB owner=sw_adm
file=E:\20130513cwdevdb.dmp log=E:\20130513cwdevdb.log
2、查看某个用户的数据库已用空间
select owner,sum(BYTES)/1024/1024 as SIZE_M from dba_segments
group by owner; --查看每个用户的已用空间
select sum(BYTES)/1024/1024 as SIZE_M from dba_segments;
--占用空间
select sum(BYTES)/1024/1024 as SIZE_M from
user_free_space;--剩余空间
3、赋权限及建同义词
给sw_app赋权限:以sw_adm用户执行以下语句,结果在cmd中执行
select 'grant select,delete,update,insert on '||object_name||'
to sw_app;' From user_objects
where object_type in('TABLE');
select 'grant select on '||object_name||' to sw_app;' From
user_objects
where object_type in('VIEW','SEQUENCE');
select 'grant execute on '||object_name||' to sw_app;' From
user_objects
where object_type
in('FUNCTION','PACKAGE','PROCEDURE','TYPE');
建同义词的语句
以sw_adm进入,执行该语句
select 'create or replace synonym '||object_name||' for
sw_adm.'||object_name||';' From user_objects
where object_type
in('FUNCTION','PACKAGE','PROCEDURE','SEQUENCE','TABLE','VIEW','TYPE');
结果以sw_app用户来执行
------------------------------------------------------------------------------------------------
a、表属主:sw_adm,拥有所有DML和DDL权限。
b、程序运行用户:sw_app,拥有sw_adm下所有对象的DML权限。
c、维护用户:sw_spt,仅有sw_adm下表和视图的查询权限。(如果需要的话)
-------------------------------------------------------------------------------------------------
adm给app账号赋完查询权限,就可以直接在app账号下建同义词了:
eg:在 sw_app这个用户下,执行这个试试建同义词:
CREATE SYNONYM AD_04_REMARK FOR sw_adm.AD_04_REMARK;
4、371520121152141153改为371520121152141153-L02样式的语句
update vat_inputinvoice a set fphm = fphm||'-L02' where
a.fplx='0002' and a.fphm not like '%L0%';
5、EXT中金额显示格式:147,925.00
{header : "结算金额", dataIndex: "total", width : 85,
align:"right",
editor : {xtype : "numberfield", allowBlank :
false},
renderer:function(v, params, record) {return
Ext.util.Format.money(v);}},