ORACLE创建用户操作

创建表空间删除并新建用户导入导出DMP文件
--sys/dba 连接
--创建表空间
CREATE TABLESPACE ecssent_zz
LOGGING
DATAFILE 'C:\app\Administrator\oradata\ora11ecss\ecssent_zz150914.dbf'
SIZE 1024m
AUTOEXTEND ON
NEXT 50m MAXSIZE 10240m
EXTENT MANAGEMENT LOCAL;
--删除表空间
DROP TABLESPACE ecsscuszz INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINT ;


--1.删除用户
DROP USER ecssent_zz CASCADE;
--查询并关闭占用的连接,不行就重启数据库服务
SELECT v.USERNAME,v.SID,v.SERIAL# FROM v$session v WHERE v.USERNAME = 'ecssent_zz' ORDER BY v.USERNAME;
ALTER SYSTEM KILL SESSION '32,757';
ALTER SYSTEM KILL SESSION '36,13';


--2.新建用户(直接在plsql视图中创建)
-- Create the user 
create user ecssent_zz IDENTIFIED BY dbwork
  default tablespace ecssent_zz
  temporary tablespace TEMP
  profile DEFAULT;
-- Grant/Revoke role privileges 
grant connect to ecssent_zz;
grant resource to ecssent_zz;
grant DBA to ecssent_zz;
-- Grant/Revoke system privileges 
grant unlimited tablespace to ecssent_zz;


--3.命令行导出DMP文件
exp ecssent_zz/dbwork@ORA11ECSS file=c:\ecssent_zz.dmp full=y
exp ecssent_zz/dbwork@ECSSCUSZZ225 file=c:\ecssent_zz_20150113.dmp log=c:\ecssent_zz_20150113.log owner=ecssent_zz COMPRESS=y


--3.命令行导入DMP文件
imp ecssentxc/dbwork@ORA11ECSS file=c:\ora11ent_20150109000001.dmp ignore=y fromuser=ecssent touser=ecssentxc
imp ecssent_zz/dbwork@ORA11ECSS file=c:\ora11cus_20150109000001.dmp ignore=y statistics=NONE buffer=10240000 COMMIT=y fromuser=ecsscus touser=ecsscuszz


--4.查看当前使用的服务连接串。92数据库有问题,无法直接导入数据,从225导入即可。
tsnping ORA11ECSS
sqlplus ecssentxc/dbwork@ora11ecss


--5.查询现场数据是否导入
SELECT COUNT(*) FROM personal_declare_head;
SELECT COUNT(*) FROM ORDER_HEAD;
SELECT COUNT(*) FROM Logistics_Information;
SELECT COUNT(*) FROM Order_Payment_Logistics;

查看表空间并更改大小

--1、查看表空间
SELECT B.FILE_NAME 物理文件名,
       B.TABLESPACE_NAME 表空间,
       B.BYTES / 1024 / 1024 大小M,
       (B.BYTES - SUM(NVL(A.BYTES, 0))) / 1024 / 1024 已使用M,
       SUBSTR((B.BYTES - SUM(NVL(A.BYTES, 0))) / (B.BYTES) * 100, 1, 5) 利用率
  FROM DBA_FREE_SPACE A, DBA_DATA_FILES B
 WHERE A.FILE_ID = B.FILE_ID
 GROUP BY B.TABLESPACE_NAME, B.FILE_NAME, B.BYTES
 ORDER BY B.TABLESPACE_NAME
--2.更改表空间大小
ALTER TABLESPACE SPACE ADD DATAFILE 'C:\APP\ADMINISTRATOR\ORADATA\ORA11ECSS\ECSSCUSZZ_01.DBF' SIZE 200m;

========================================================================
<span style="font-family: Arial, Helvetica, sans-serif;">create user xurui identified by xurui; --创建用户并确定密码</span>
grant dba to xurui; --给用户dba权限
DROP USER xurui CASCADE;--删除用户

grant create session to ocrquery; --授权会话
grant select on LDCODE to ocrquery; --授权查询指定表
grant select on LDCODE1 to ocrquery; --授权查询指定表

grant select any table to ocr;--授予查询任何表  
grant select any dictionary to ocr;--授予 查询任何字典  

SELECT * FROM ALL_USERS; --查询所有用户
SELECT * FROM ALL_ALL_TABLES; --查询所有表
D:\oracle\product\10.2.0\db_1\network\ADMIN\tnsnames.ora
# XURUI/XURUI 用户名密码
XURUI =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = XXR 本地主机名或者用 HOST = 10.10.164.53)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = xxr 数据库的名称)
    )
  )
#############以sys用户 创建表空间###################

create tablespace CCBTestDB_DATA datafile 'F:\oracle\product\10.2.0\oradata\orcl\CCBTestDB_DATA.ora' 
size 100M autoextend on next 10M maxsize unlimited default
 storage(initial 128K next 128K minextents 5 maxextents unlimited);


#############以sys用户 创建用户###################

create user ccbimage identified by ccbimage default tablespace CCBTestDB_DATA;

grant dba,connect,resource,select any table,delete any table,update any table,insert any table to ccbimage;

###########以ccbimage用户登录 执行建库脚本############################################
【博客园】oracle用户创建及权限设置

你可能感兴趣的:(oracle,数据库,plsql)