--==cmd控制台==--
--==日常用户管理SQL==--
--连接到SQLPLUS
>sqlplus /nolog
--以dba身份连接
sql>conn / as sysdba
--修改用户密码 将system用户的密码修改成system
sql>alter user system identified by "system"
--连接 sql>conn
请输入用户名:system
输入口令:
--查询所有用户
sql>select * from user_users;
sql>select * from all_users;
--删除用户clsp及其下面的所有表
sql>drop user clsp cascade
--创建用户并赋予dba权限
sql>create user clsuser identified by "cls";//oracle12c时用户名前需加上c##
sql>grant dba to clsuser;
grant all privileges to clsuser;
--oracle 12c
DROP USER C##CLSP0616 CASCADE;
create user C##CLSP0616 identified by "C##CLSP0616";
grant dba to C##CLSP0616;
grant all privileges to C##CLSP0616;
--修改通过PL/SQL创建的用户
C:\Users\User>sqlplus test/123456@orcl as sysdba
SQL> alter user test0918 identified by test0918;
--==数据库导入导出==--
C:\Users\User>sqlplus system/test0506@orcl92 as sysdba
drop tablespace test_data including contents and datafiles;//删除表空间,同时删除数据文件:
SQL> create tablespace CFFGLOANSPACE datafile 'F:\oracle12\oracle12Data\CFFGLOANSPACE.dbf' size 600m autoextend on next 30m MAXSIZE UNLIMITED;
DROP TABLESPACE cffgloanspace INCLUDING CONTENTS AND DATAFILES;//删除表空间
SQL> create user test0902 identified by test0506 default tablespace cffg92;
SQL> grant dba to test0902;
SQL> imp test0902/test0506@orcl92 file=F:\2015-9-2.dmp full=y;
--导入数据库 imp username/password@[ip/]oracle数据库实例名 file=路径\xx.dmp [full=y]; 当full=y时如果要忽略警告信息可以加上 ignore=y
sql>imp clsuser/cls@orcl file=e:\p2p.dmp full=y;
C:\Users\User>imp test0903/test0506@orcl file=F:\2015-9-2.dmp fromuser=clspuser touser=test0903 老大
sql>imp xxfbgswl/xxfbgswl@zbx25 file=e:\gswl20130424.dmp fromuser=gswl touser=xxfbgswl log=e:xxfblog.log rows=y --导出数据库
C:\Users\User>imp hbus\hbus@hbus file=F:\test0506.dmp fromuser=test0506 touser=hbus ignore=y
导出dmp命令:【非本地数据库在@后添加ip/】exp username/password@oracle数据库实例名 file=存放导出路径\XXX.dmp(如file=E:\导入导出\export.dmp)
sql>exp gswleq/gswleq@dlzbx file=D:\gswl0619.dmp log=gswl.log owner=(gswleq) rows=y;
sql>exp gswleq/gswleq@dlzbx file=D:\gswl0619.dmp full=y;
//导出指定用户的
exp gswleq/gswleq@dlzbx file=D:\gswl0619.dmp owner=gswleq;