发包时DB配置的两种方式
一. Toad下直接导入开发release的Dmp文件
1. 用schema: (所用测试数据库的schema)登陆Toad
2. click the “Database” on the menu, then click the “schema browser”
3. 在左侧Tables中全选所有的Tables(注意其中不要有过滤条件),然后右键点击所有选中的Tables,点击 ”Drop Table” .
4. 在跳出的confirm windows中,选中那两个checkbox(Cascade Constraint与Purge),然后点击”yes”,此schema中所有的Table都被drop掉了.
5. 在左侧Sequences中全选所有的Tables(注意其中不要有过滤条件),然后右键点击所有选中的Tables,点击 ”Drop Sequences” .-->confirm
6. 点击菜单栏上的”commit” button,然后断开此schema的连接.
7. 再用schema:(所用数据库的schema)登陆Toad
8. 查看此schema下所有表是否都已被删除了.
9. click the “DBA” on the menuà click the “Data Import/Export” in “DBA” àclick the “Import Utility Wizard” in “Data Import/Export” àselect the radio button of the “Import Tables”(default selected) àclick the “next button” àinput the “from user”(ndms04) and “to user”(所用的schema) àclick the “next” button à click the “next” buttonàselect the path of the released dmp. à click the “next” button à click the “finish” button
10. 查看import是否有错误,完成后点击菜单栏上的”commit” button.
二. 在LINUX下用SQL命令导入表.
每次发包时,请按照如下步骤,导入SCHEMA及删除以前的SCHEMA。
1.将开发release的DMP文件上传到LINUX SERVER上
2.登陆LINUX(用SSH1协议连接,Hostname: 10.0.6 .42, 用户名:root 密码: suzsoft)
cd /opt/oracle
rm –rf 以前的ndms文件
rz(打开上传框,将该imp文件及SEQUENCE的SQL文件上传到LINUX上)
2.进入SQL PLUS
su - oracle
cd /opt/oracle/product/ 10g /bin/
sqlplus /nolog
conn / as sysdba
3、删除以前的用户:
drop user 用户名cascade;(删除只读用户)
如果drop不成功的话,可用如下命令先kill掉此schema的连接:
select username,sid,serial# from v$session; (查看oracle 连接用户参数)
alter system disconnect session 'sid,serial#' post_transaction immediate;(断开此用户的连接)
或用alter system kill session ‘sid,serial#’;(断开此用户的进程,建议用前一种方法,此方法会造成数据丢失).
4、建立新用户并赋权限
a.赋权限给管理员
create user 用户名 identified by 密码 default tablespace emms temporary tablespace temp;
grant connect, resource to ndms;(赋权限给管理schema所有者用户)
grant unlimited tablespace to ndms;
b. 赋权限给只读用户
create user 用户名 identified by 密码 default tablespace emms temporary tablespace temp;
grant create session to ndms01;
grant select any table to ndms01;(赋权限给只读用户)
5、退出SQL PLUS
exit;
6、导入SCHEMA
export NLS_LANG=AMERICAN_AMERICA.UTF8(重新定义字符集,导入DMP文件前必须操作,才能使导入能与导出的UNIX字符集一致)(DOS下是set)
imp 用户名/密码 file=/opt/oracle/刚刚上传的DMP文件 full=y buffer=10240 ignore=Y
7. 如何查看oracle連接的用戶數量
select * from v$session where username is not null;
or
select count(*) from v$session where username is not null;
8. Oracle对非正常断开或kill连接的清理
SQL> select username,sid,serial# from v$session;
如果要停某个连接用
SQL> alter system kill session ‘sid,serial#’;
如果这命令不行,找它UNIX的进程数
SQL> select pro.spid from v$session ses,v$process pro where ses.sid=21 and ses.paddr=pro.addr; 说明:21是某个连接的sid数
kill session有点问题,不能立刻释放进程
可以试一下这个:alter system disconnect session 'sid,serial#' post_transaction immediate;这个会立即释放会话及相应的进程,
9.导入DMP文件
imp ndms109/ndms109@ndmsqa fromuser=ndms01 touser=ndms109 file=d:/ndms.dmp log=imp.log grants=n
exp ndms01/ndms01@dev owner=ndms01 file=d:/ndms.dmp log=d:/exp.log
imp ndms109/ndms109@ndmsqa file=d:/ndms.dmp tables=(CMM_WFL_PRCS_XML)
10.重启数据库
Connect /as sysdba;
Shutdown immediate;
Startup;
Drup user 用户名 CASCADE;
DROP USER QUOTA CASCADE