Guest User

Untitled

a guest
Oct 16th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 KB | None | 0 0
  1. - connect: connects to a database
  2. - disconnect: logs off but does not exit
  3. - exit: exists
  4.  
  5. / as sysdba
  6.  
  7. SQL> create user johny identified by 1234;
  8.  
  9. SQL> select username from dba_users;
  10.  
  11. ERROR:
  12. ORA-01045: user JOHNY lacks CREATE SESSION privilege; logon denied
  13.  
  14. SQL> grant create session to johny;
  15.  
  16. username: johny
  17. password: 1234
  18.  
  19. SQL> drop user johny;
  20.  
  21. SQL> select tablespace_name from dba_tablespaces;
  22.  
  23. SQL> create tablespace johny_tabspace
  24. 2 datafile 'johny_tabspace.dat'
  25. 3 size 10M autoextend on;
  26.  
  27. SQL> create temporary tablespace johny_tabspace_temp
  28. 2 tempfile 'johny_tabspace_temp.dat'
  29. 3 size 5M autoextend on;
  30.  
  31. SQL> create user johny
  32. 2 identified by 1234
  33. 3 default tablespace johny_tabspace
  34. 4 temporary tablespace johny_tabspace_temp;
  35.  
  36. SQL> grant create session to johny;
  37. SQL> grant create table to johny;
  38. SQL> grant unlimited tablespace to johny;
  39.  
  40. SQL> select * from session_privs;
  41.  
  42. PRIVILEGE
  43. ----------------------------------------
  44. CREATE SESSION
  45. UNLIMITED TABLESPACE
  46. CREATE TABLE
  47.  
  48. SQL> create table johny_table
  49. 2 (
  50. 3 id int not null,
  51. 4 text varchar2(1000),
  52. 5 primary key (id)
  53. 6 );
  54.  
  55. SQL> insert into johny_table (id, text)
  56. 2 values (1, 'This is some text.');
  57.  
  58. SQL> select * from johny_table;
  59.  
  60. ID TEXT
  61. --------------------------
  62. 1 This is some text.
  63.  
  64. SQL> set pagesize 0
  65. SQL> set long 90000
  66. SQL> set feedback off
  67. SQL> set echo off
  68. SQL> SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name) FROM USER_TABLES u;
  69.  
  70. CREATE TABLE "JOHNY"."JOHNY_TABLE"
  71. ( "ID" NUMBER(*,0) NOT NULL ENABLE,
  72. "TEXT" VARCHAR2(1000),
  73. PRIMARY KEY ("ID")
  74. USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
  75. STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  76. PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DE
  77. FAULT CELL_FLASH_CACHE DEFAULT)
  78. TABLESPACE "JOHNY_TABSPACE" ENABLE
  79. ) SEGMENT CREATION IMMEDIATE
  80. PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  81. STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  82. PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DE
  83. FAULT CELL_FLASH_CACHE DEFAULT)
  84. TABLESPACE "JOHNY_TABSPACE"
  85.  
  86. SQL> set pagesize 0
  87. SQL> set long 90000
  88. SQL> set feedback off
  89. SQL> set echo off
  90. SQL> SELECT DBMS_METADATA.GET_DDL('INDEX',u.index_name) FROM USER_INDEXES u;
  91.  
  92. CREATE UNIQUE INDEX "JOHNY"."SYS_C0013353" ON "JOHNY"."JOHNY_TABLE" ("ID")
  93. PCTFREE 10 INITRANS 2 MAXTRANS 255
  94. STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  95. PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DE
  96. FAULT CELL_FLASH_CACHE DEFAULT)
  97. TABLESPACE "JOHNY_TABSPACE"
  98.  
  99. SQL> select Username from dba_users
  100. 2 ;
  101.  
  102. USERNAME
  103. ------------------------------
  104. SYS
  105. SYSTEM
  106. ANONYMOUS
  107. APEX_PUBLIC_USER
  108. FLOWS_FILES
  109. APEX_040000
  110. OUTLN
  111. DIP
  112. ORACLE_OCM
  113. XS$NULL
  114. MDSYS
  115.  
  116. USERNAME
  117. ------------------------------
  118. CTXSYS
  119. DBSNMP
  120. XDB
  121. APPQOSSYS
  122. HR
  123.  
  124. 16 rows selected.
  125.  
  126. SQL> create user testdb identified by password;
  127.  
  128. User created.
  129.  
  130. SQL> select username from dba_users;
  131.  
  132. USERNAME
  133. ------------------------------
  134. TESTDB
  135. SYS
  136. SYSTEM
  137. ANONYMOUS
  138. APEX_PUBLIC_USER
  139. FLOWS_FILES
  140. APEX_040000
  141. OUTLN
  142. DIP
  143. ORACLE_OCM
  144. XS$NULL
  145.  
  146. USERNAME
  147. ------------------------------
  148. MDSYS
  149. CTXSYS
  150. DBSNMP
  151. XDB
  152. APPQOSSYS
  153. HR
  154.  
  155. 17 rows selected.
  156.  
  157. SQL> grant create session to testdb;
  158.  
  159. Grant succeeded.
  160.  
  161. SQL> create tablespace testdb_tablespace
  162. 2 datafile 'testdb_tabspace.dat'
  163. 3 size 10M autoextend on;
  164.  
  165. Tablespace created.
  166.  
  167. SQL> create temporary tablespace testdb_tablespace_temp
  168. 2 tempfile 'testdb_tabspace_temp.dat'
  169. 3 size 5M autoextend on;
  170.  
  171. Tablespace created.
  172.  
  173. SQL> drop user testdb;
  174.  
  175. User dropped.
  176.  
  177. SQL> create user testdb
  178. 2 identified by password
  179. 3 default tablespace testdb_tablespace
  180. 4 temporary tablespace testdb_tablespace_temp;
  181.  
  182. User created.
  183.  
  184. SQL> grant create session to testdb;
  185.  
  186. Grant succeeded.
  187.  
  188. SQL> grant create table to testdb;
  189.  
  190. Grant succeeded.
  191.  
  192. SQL> grant unlimited tablespace to testdb;
  193.  
  194. Grant succeeded.
  195.  
  196. SQL>
  197.  
  198. CREATE USER auto_exchange IDENTIFIED BY 123456;
  199. GRANT RESOURCE TO auto_exchange;
  200. GRANT CONNECT TO auto_exchange;
  201. GRANT CREATE VIEW TO auto_exchange;
  202. GRANT CREATE SESSION TO auto_exchange;
  203. GRANT UNLIMITED TABLESPACE TO auto_exchange;
Add Comment
Please, Sign In to add comment