1,创建临时表空间
查看复制打印?
- SQL> create temporary tablespace test_temp
- 2 tempfile '/opt/ora10/oradata/test/test_tmp.dbf'
- 3 size 32m
- 4 autoextend on
- 5 next 32m maxsize 148m
- 6 extent management local;
-
- Tablespace created.
2,创建表空间
查看复制打印?
- SQL> create tablespace test_data
- 2 logging
- 3 datafile '/opt/ora10/oradata/test/test_data.dbf'
- 4 size 32m
- 5 autoextend on
- 6 next 32m maxsize 148m
- 7 extent management local;
-
- Tablespace created.
3,创建表用户,并表空间分配给用户
查看复制打印?
- SQL> create user tank identified by tank
- 2 default tablespace test_data
- 3 temporary tablespace test_temp;
-
- User created.
4,查看创建的表空间
查看复制打印?
- SQL> select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
- 2 from dba_tablespaces t, dba_data_files d where
- 3 t.tablespace_name = d.tablespace_name group by t.tablespace_name;
-
- TABLESPACE_NAME TS_SIZE
- ------------------------------ ----------
- SYSAUX 240
- UNDOTBS1 25
- TEST_DATA 32
- USERS 5
- SYSTEM 480
5,查看临时表空间
查看复制打印?
- SQL> select sum(bytes)/1024/1024 "temp size(M)" from dba_temp_files where tablespace_name='TEST_TMP';
-
- temp size(M)
- ------------
6,将表空间的部分操作权限分配给用户
- SQL> grant connect,resource to tank;
-
- Grant succeeded.
7,resource这是一个权限组,有这个组就不要一个一个加了。
- SQL> select GRANTEE,PRIVILEGE from DBA_SYS_PRIVS where GRANTEE ='RESOURCE';
-
- GRANTEE PRIVILEGE
- ------------------------------ ----------------------------------------
- RESOURCE CREATE TRIGGER
- RESOURCE CREATE SEQUENCE
- RESOURCE CREATE TYPE
- RESOURCE CREATE PROCEDURE
- RESOURCE CREATE CLUSTER
- RESOURCE CREATE OPERATOR
- RESOURCE CREATE INDEXTYPE
- RESOURCE CREATE TABLE
-
- 8 rows selected.
以下操作我都是能以tank这个用户进行操作的
9,创建表
- create table test(
- id number(10) not null primary key,
- name varchar(2) null ,
- city number(1) null
- );
10,创建临时表
- CREATE GLOBAL TEMPORARY TABLE test1 (
- id number(10) not null primary key,
- name varchar(2) null ,
- city number(1) null
- );
11,查看表
- SQL> select distinct table_name from user_tables;
-
- TABLE_NAME
- ------------------------------
- TEST
- TEST1
-
- //或者
- SQL> select table_name from dba_tables where owner='TANK';
-
- TABLE_NAME
- ------------------------------
- TEST
- TEST1
注意大小写