oracle创建新用户和用户表空间

1.首先,创建(新)用户:
create user username identified by password;
username:新用户名的用户名
password: 新用户的密码
也可以不创建新用户,而仍然用以前的用户,如:继续利用scott用户

2.创建表空间:
create tablespace tablespacename datafile ‘d:\data.dbf‘ size xxxm;
tablespacename:表空间的名字
d:\data.dbf‘:表空间的存储位置
xxx表空间的大小,m单位为兆(M)
3.将空间分配给用户:
alter user username default tablespace tablespacename;
将名字为tablespacename的表空间分配给username

4.给用户授权:
grant create session,create table,unlimited tablespace to username;
grant create session,create table,unlimited tablespace to NAMEMATCHER;

5.然后再以楼主自己创建的用户登录,登录之后创建表即可。
conn username/password;

6.查看服务名
env |grep SID

7.授予dba权限
grant dba to username

7.使用上面的用户名、密码、sid登录plsql

每步执行的sql:(sjzx是数据库名、用户名、密码、表空间名)
(1)create user sjzx identified by sjzx
(2)create tablespace sjzx datafile ‘D:\db\app\oradata\orcl\sjzx.dbf‘
size 100m
autoextend on next 32m maxsize 2048m

(3)alter user sjzx default tablespace sjzx

(4)grant create session,create table,unlimited tablespace to sjzx

1.创建用户
create user user_name identified by "user_password"
default tablespace tbs_name
temporary tablespace temp profile DEFAULT;

2.授权
grant connect to user_name;
grant create indextype to user_name;
grant create job to user_name;
grant create materialized view to user_name;
grant create procedure to user_name;
grant create public synonym to user_name;
grant create sequence to user_name;
grant create session to user_name;
grant create table to user_name;
grant create trigger to user_name;
grant create type to user_name;
grant create view to user_name;
grant unlimited tablespace to user_name;
alter user user_name quota unlimited on tbs_name;
==================================================================
--查询用户默认使用的表空间
select username,default_tablespace from dba_users;
--修改默认表空间
alter user TRANSWATCH default tablespace TMS5_TABLES;
--给用户赋权限
grant create session,create table,unlimited tablespace to TRANSWATCH;
--查询用户使用的表空间
select table_name,tablespace_name from user_tables;
--查指定表空间下当前用户的所有表
select ‘alter table ‘||table_name||‘ move tablespace TMS5_TABLES;‘ from
user_tables where tablespace_name = ‘USERS‘;
--批量修改表空间
alter table SANCTIONED_CITIES move tablespace TMS5_TABLES;
...
--查询索引
select * from user_indexes;
--查指定索引表空间下当前用户的所有=索引
select ‘alter index ‘||index_name||‘ rebuild tablespace TMS5_INDEXES;‘from user_indexes;
--批量修改索引表空间
alter index SYS_IL0000077055C00004$$ rebuild tablespace TMS5_INDEXES;
alter index PK_SUPPORT_FILES rebuild tablespace TMS5_INDEXES;
...
--查询函LOB类型表所在索引表空间(ORA-02327: cannot create index on expression with datatype LOB 02327. 00000,报这个错是因为LOB类型导致)
select * from user_indexes where index_name like ‘SYS%‘
--表结构
desc SCREENING_IWL_ENTITY;
--移动含LOB类型表的索引到其他表空间
ALTER TABLE SCREENING_IWL_ENTITY MOVE LOB(DETAIL) STORE AS (TABLESPACE TMS5_INDEXES);

原文地址:https://www.cnblogs.com/liutoliu/p/11818659.html

时间: 2024-08-04 15:09:19

oracle创建新用户和用户表空间的相关文章

Oracle学习历程--创建用户,分配表空间

记录下学习Oracle12c的过程中的点点滴滴. Oracle12c新特性:http://www.cnblogs.com/kerrycode/p/3386917.html --创建临时表空间CREATE TEMPORARY TABLESPACE ADMIN_TEMPTEMPFILE '文件的绝对路径'//如:'J:\software\myOracle\oradata\orcl\TEMP.DBF'SIZE 50MAUTOEXTEND ONNEXT 50 MAXSIZE 100MEXTENT MAN

Oracle开发:创建一个用户并分配表空间和分配权限

-- 创建一个用户并分配表空间和分配权限 -- 以sysdba登录 [email protected]:~> sqlplus / as sysdba SQL*Plus: Release 12.1.0.2.0 Production on Mon Mar 7 18:48:59 2016 Copyright (c) 1982, 2014, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition

Oracle 创建表空间、临时表空间、创建用户并指定表空间、授权,删除用户及表空间

/* 说明:若已经存在相应的用户和表空间,则需要先删除相应的用户和表空间 然后再全部重新建立 */ --删除用户 drop user USERNAME cascade; --删除表空间 drop tablespace DATA_TEMP including contents and datafiles; drop tablespace DATA including contents and datafiles; --创建临时表空间 create temporary tablespace DATA

Oracle12c:安装后新建用户及其默认表空间,并创建表测试

环境: 操作系统:Windows Server2008 R2 X64 Oracle版本:12c 如何安装? -- oracle 12c在oracle linux 6.6 x64上的安装 -- Windows x64位下完美安装winx64_oracle_12c_database 如何使用DataBase Cofiguration Assistant 创建数据库? -- oracle12c dbca方式创建数据库实例(多图) 如何使用PL/SQL Developer连接? -- PL/SQL De

Oracle创建新用户

1.以DBA身份登录 $ sqlplus sys/[email protected] as sysdba(在命令窗口下) 也可以使用PL/SQL 2.创建临时表空间 1 create temporary tablespace jiashubing_temp 2 tempfile 'E:\app\USER\oradata\orcl\jiashubing_temp.dbf' 3 size 100m 4 autoextend on next 32m 5 maxsize 2048m 6 extent m

创建表空间、创建用户并指定表空间

/*分为四步 *//*第1步:创建临时表空间  */create temporary tablespace yuhang_temp tempfile 'D:\oracledata\yuhang_temp.dbf' size 50m  autoextend on  next 50m maxsize 20480m  extent management local;   /*第2步:创建数据表空间  */create tablespace yuhang_data  logging  datafile

oracle 用户 多个表空间

首先,授权给指定用户. 一个用户的默认表空间只能有一个,但是你可以试下用下面的语句为其授权在别的表空间中创建对像: alter user  username quota 0||unlimited on tablespace_name; 再者,创造表的命令. 一个用户可以拥有多个表空间在创建表时: create table TABLE_NAME () tablespace TABLESPACE_NAME;这样你所创建的表便在指定的空间下了. 最后,至于查询,插入等这些你是懂的……

表空间与用户的关系 表空间和数据文件的关系 schema

一个表空间有多个数据文件,一个数据文件只能属于一个表空间. 一个数据库可以有多个表空间,每一个库都有一个system表空间. 一个用户可以使用一个或多个表空间,一个表空间也可以供多个用户使用. 用户和表空间没有隶属关系,表空是一个用来管理数据存储逻辑概念,表空间只是和数据文件发生关系,数据文件是物理的,一个表空间可以包含多个数据文件,而一个数据文件只能隶属一个表空间. 用户在创建表的时候没有指定表空间,使用该用户的默认表空间(创建用户的时候需要指定). 方案(schema)又叫模式,是比表空间小

expdp 和impdp使用之一(不同用户和不用表空间)

1.创建DIRECTORY SQL> create or replace directory dir_dp as '/fol/dir_dp'; Directory created. 2.授权 SQL> grant read,write on directory dir_dp to scott; Grant succeeded. 3.查看目录及权限 SQL> set lines 200 pagesize 1000 SQL> SELECT privilege, directory_na