Friday, July 18, 2014

create test database and roles in a fresh oracle install


See here to install oracle and sqlplus.

Connect to oracle as system or sysdba
BASH> rlwrap $ORACLE_HOME/bin/sqlplus -L system/INIT_PASSWORD@//localhost:1521/

Create a test database:
SQL> create bigfile tablespace test datafile 'test.dat' size 32m autoextend on nologging;

Tablespace created.

Create a test user:
SQL> create role tester; 

Role created.

SQL> grant connect, resource, dba to tester;

Grant succeeded.

SQL> create user tester1 identified by SECRET default tablespace test;

User created.

SQL> grant tester to tester1;

Grant succeeded.

SQL> alter user tester1 quota unlimited on test;

User altered.

SQL> quit

...

Now try to connect to oracle using the newly created user
BASH> rlwrap $ORACLE_HOME/bin/sqlplus -L tester1/SECRET@//localhost:1521

Create a test table and insert some random value
SQL> create table tab0(k number(10) not null, v varchar2(32) not null) tablespace test;

Table created

SQL> insert into tab0 (k,v) values (1, 'test value');
1 row created.

SQL> select * from tab0;
         K V
---------- --------------------------------
         1 test value


No comments:

Post a Comment