




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、一、创建表空间及用户并授权1:创建临时表空间create temporary tablespace user_tempsize 50mautoextend onnext 50m maxsize 20480mextent management local;2:创建数据表空间create tablespace user_dataloggingsize 50mautoextend onnext 50m maxsize 20480mextent management local;第3步:创建用户并指定表空间create user username identified by passworddefau
2、lt tablespace user_datatemporary tablespace user_temp;第4步:给用户授予权限grant connect,resource,dba to username;第二部分:删除用户及表空间/删除用户以及用户所有的对象drop user zfmi cascade;/cascade参数是级联删除该用户所有对象,经常遇到如用户有对象而未加此参数则用户删不了的问题,所以习惯性的加此参数/删除表空间前提:删除表空间之前要确认该表空间没有被其他用户使用之后再做删除drop tablespace zfmi including contents and dataf
3、iles cascade onstraints;/including contents 删除表空间中的内容,如果删除表空间之前表空间中有内容,而未加此参数,表空间删不掉,所以习惯性的加此参数/including datafiles 删除表空间中的数据文件/cascade constraints 同时删除tablespace中表的外键参照二、oracle数据库的导入和导出下面介绍的是导入导出的实例,向导入导出看实例基本上就可以完成,因为导入导出很简单。数据导出:1 将数据库TEST完全导出,用户名system 密码manager 导出到D:daochu.dmp中exp system/manage
4、rTEST file=d:daochu.dmp full=y2 将数据库中system用户与sys用户的表导出exp system/managerTEST file=d:daochu.dmp owner=(system,sys3 将数据库中的表table1 、table2导出exp system/managerTEST file=d:daochu.dmp tables=(table1,table24 将数据库中的表table1中的字段filed1以"00"打头的数据导出exp system/managerTEST file=d:daochu.dmp tables=(tabl
5、e1 query=" where filed1 like '00%'"上面是常用的导出,对于压缩我不太在意,用winzip把dmp文件可以很好的压缩。不过在上面命令后面加上compress=y 就可以了数据的导入1 将D:daochu.dmp 中的数据导入TEST数据库中。imp system/managerTEST file=d:daochu.dmp上面可能有点问题,因为有的表已经存在,然后它就报错,对该表就不进行导入。在后面加上ignore=y 就可以了。2 将d:daochu.dmp中的表table1 导入imp system/managerTEST
6、file=d:daochu.dmp tables=(table1基本上上面的导入导出够用了。不少情况我是将表彻底删除,然后导入。注意:你要有足够的权限,权限不够它会提示你。数据库时可以连上的。可以用tnsping TEST 来获得数据库TEST能否连上。数据导出:exp hkb/hkbboss_14 full=y file=c:orabackuphkbfull.dmp log=c:orabackuphkbfull.log; 导出注意事项:导出的是当前用户的的数据,当前用户如果有DBA的权限,则导出所有数据!同名用户之间的数据导入:imp hkb/hkbxe file=c:orabackuphk
7、bfull.dmp log=c:orabackuphkbimp.log full=y不同名之间的数据导入:imp system/testxe fromuser=hkb touser=hkb_new file=c:orabackuphkbfull.dmplog=c:orabackuphkbimp.log;三、相关的更改语句(alter的用法/0.重命名/0.1 表:rename dept to dt;rename dt to dept;/0.2 列:alter table dept rename column loc to location;alter table dept rename col
8、umn location to loc;/1.添加约束/1.1 primary keyalter table employee_info add constraint pk_emp_info primary key(empno; /1.2 foreign keyalter table employee_info add constraint fk_emp_info foreign key(deptnoreferences dept(deptno;/1.3 checkalter table employee_info add constraint ck_emp_info check(sex in
9、 ('F','M'/1.4 not nullalter table employee_info modify phone constraint not_null_emp_info not null; /1.5 uniquealter table employee_info add constraint uq_emp_info unique(phone;/1.6 defaultalter table employee_info modify sex char(2 default 'M'/2.添加列alter table employee_info
10、add id varchar2(18;alter table employee_info add hiredate date default sysdate not null;/3.删除列alter table employee_info drop column introduce;/3.修改列/3.1 修改列的长度alter table dept modify loc varchar2(50;/3.2 修改列的精度alter table employee_info modify empno number(2;/3.3 修改列的数据类型alter table employee_info mod
11、ify sex char(2;/3.4 修改默认值alter table employee_info modify hiredate default sysdate+1;/4.禁用约束alter table employee_info disable constraint uq_emp_info;/5.启用约束alter table employee_info enable constraint uq_emp_info;/6.延迟约束alter table employee_info drop constraint fk_emp_info;alter table employee_info a
12、dd constraint fk_emp_info foreign key(deptno references dept(deptnodeferrable initially deferred;/7.向表中添加注释comment on table employee_info is 'information of employees'/8.向列添加注释comment on column employee_info.ename is 'the name of employees' comment on column dept.dname is 'the na
13、me of department'/9.清除表中所有数据truncate table employee_info;/10.删除表drop table employee_info;/11修改session默认时间格式alter session set nls_date_format ='yyyy-mm-dd'alter session set nls_date_format = 'yyyy-mm-dd hh24:mi:ss'/12修改用户密码Alter user user_name identified by password./13 修改最大连接数第一步
14、,在cmd命令行,输入sqlplus第二步源码天空,根据提示输入用户名与密码1. 查看processes和sessions参数SQL> show parameter processesNAME TYPE VALUEdb_writer_processes integer 1gcs_server_processes integer 0job_queue_processes integer 10log_archive_max_processes integer 2processes integer 50SQL> show parameter sessionsNAME TYPE VALUE
15、license_max_sessions integer 0license_sessions_warning integer 0logmnr_max_persistent_sessions integer 1sessions integer 60shared_server_sessions integer2. 修改processes和sessions值SQL> alter system set processes=300 scope=spfile;系统已更改。SQL> alter system set sessions=335 scope=spfile;系统已更改。3. 修改pro
16、cesses和sessions值必须重启oracle服务器才能生效ORACLE的连接数(sessions与其参数文件中的进程数(process有关,它们的关系如下: sessions=(1.1*process+5摘(二查询数据库当前进程的连接数:select count(* from v$process;查看数据库当前会话的连接数:elect count(* from v$session;查看数据库的并发连接数:select count(* from v$session where status='ACTIVE'查看当前数据库建立的会话情况:select sid,serial#
17、,username,program,machine,status from v$session;查询数据库允许的最大连接数:select value from v$parameter where name = 'processes'或者:show parameter processes;修改数据库允许的最大连接数:alter system set processes = 300 scope = spfile;(需要重启数据库才能实现连接数的修改重启数据库:shutdown immediate;startup;查看当前有哪些用户正在使用数据:select osuser,a.use
18、rname,cpu_time/executions/1000000|'s',sql_fulltext,machine from v$session a,v$sqlarea b where a.sql_address = b.address order by cpu_time/executions desc; 备注:UNIX 1 个用户 session 对应一个操作系统 process,而 Windows 体现在线程。 启动 oracle su - oracle sqlplus system/pwd as sysdba /进入 sql startup lsnrctl start sqlplus "/as sysdba" shutdown immediate; startup mount; alter database open; 三、如何查询数据库该用户下所有表及表中字段的备注名称 select table_name from user_tables; /当前用户拥有的表 select table_name from all_tables; /所有用户的表 select table_name from dba_tables; /包括系统表 select table_name from dba_tables where
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 班组管理安全培训
- 入场安全教育培训
- 大班颠倒世界课件
- IBM内部咨询培训
- 二零二五年度夫妻离婚协议中共同债务承担与信用修复协议
- 二零二五版电力设施智能化设计及报批合同
- 二零二五年度智能交通系统采购合同及数据共享协议
- 二零二五年度加油站客户关系管理与维护服务合同
- 2025版工程合同防坑四要素合同条款解读
- 二零二五年度建筑行业电工操作规范用工合同
- 2025秋部编版(2024)八年级上册语文上课课件 第三单元 阅读综合实践
- TZZB3051-2023电气绝缘用玻璃纤维增强不饱和聚酯块状阻燃模塑料UP-BMC
- 企业职务津贴管理制度
- 足外翻康复训练讲课件
- “AI+知识图谱”赋能高职院校金课建设的研究与实践
- 含氰废水破氰工艺及操作详解
- 2025年贵州安大航空锻造有限责任公司-企业报告(业主版)
- 借车给他人免责协议书
- 设计总监协议书
- 物业公司各岗位制度
- 冷库施工过程中的质量控制与管理简述
评论
0/150
提交评论