Thursday, February 25, 2010

Create tablespace, user, table in oracle 10g


[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Feb 25 15:19:56 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> CREATE TABLESPACE mytbs DATAFILE '/u01/app/oracle/oradata/ORCL/datafile/mytbs.dbf' SIZE 10M;

Tablespace created.

SQL> show user
USER is "SYS"
SQL>
SQL> CREATE USER ora1 IDENTIFIED BY ora1 DEFAULT TABLESPACE mytbs;

User created.

SQL> exit

[oracle@localhost ~]$ sqlplus ora1/ora1
ERROR:
ORA-01045: user ORA1 lacks CREATE SESSION privilege; logon denied

Enter user-name:

[oracle@localhost ~]$ sqlplus / as sysdba
SQL> GRANT CONNECT TO ora1;

Grant succeeded.
SQL> connect ora1/ora1
Connected.
SQL> show user
USER is "ORA1"
SQL> CREATE TABLE ora1.table1(col1 number);
CREATE TABLE ora1.table1(col1 number)
*
ERROR at line 1:
ORA-01031: insufficient privileges
SQL> exit

[oracle@localhost ~]$ sqlplus / as sysdba

SQL> show user
USER is "SYS"
SQL> GRANT CREATE TABLE TO ora1;

Grant succeeded.

SQL> connect ora1/ora1
Connected.

SQL> show user
USER is "ORA1"

SQL> CREATE TABLE ora1.table1(col1 number);
CREATE TABLE ora1.table1(col1 number)
*
ERROR at line 1:
ORA-01950: no privileges on tablespace 'MYTBS'

SQL>exit

[oracle@localhost ~]$ sqlplus sys/oracle as sysdba
SQL> show user
USER is "SYS"
SQL> ALTER USER ora1 QUOTA UNLIMITED ON mytbs;

User altered.

SQL> connect ora1/ora1
Connected.
SQL> CREATE TABLE ora1.table1(col1 number);

Table created.

SQL>

No comments: