Dbusers and Tablespace
Dbusers and Tablespace
CREATE USER
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
==========================================================
connecting to adifferent user account on the active sql plus.
USER
-------------------------------
SYS
SQL>connect system/mala1clara
SQL> select user from dual;
USER
-------------------------------------------
SYSTEM
Create a user.
Syntax:
EXAMPLES
User created.
SQL>connect c##muna/password
common user can not access account until he/she has been granted create seesion
priviledge
SQL>connect c##muna/lab1234;
*******
SQL> connect c##muna/lab1234;
ERROR:
ORA-01045: user C##MUNA lacks CREATE SESSION privilege; logon denied
*******
therefore muna must be given privilege.
connect system/mala1clara
grant create session to c##muna;
Grant succeeded.
connect c##muna/lab1234;
USER
------------------------------
C##MUNA
Grant succeeded.
EG.
User altered.
****
SQL> connect c##muna/lab12345
Connected.
SQL> password
Changing password for C##MUNA
Old password:
New password:
Retype new password:
Password changed
****
User altered.
NOTE:
only administrators can create and manage other users.
connect c##muna/lab1234;
connect system/mala1clara;
Grant succeeded.
Table created.
SQL> desc emp;
Name Null? Type
----------------------------------------- --------
ID NUMBER
ENAME VARCHAR2(4)
connect system/mala1clara;
SQL> connect system/mala1clara;
Connected.
Grant succeeded.
connect c##muna/lab1234;
ID ENAM
---------- ----
1 H
1 H
=========================================================
==ROLE:
(set of priviledges created for user of same category)
Role created.
SQL>
GRANT CREATE session, CREATE table, CREATE view,
CREATE procedure,CREATE synonym
TO c##managers;
Grant succeeded.
now you can grant this role to user c##muna who is on manager categories.
Grant succeeded.
==> t denie/reject privildges
revoke c##managers from c##muna;
========================************====================
GRANT conn TO MySchemaOwner;
You have to create a user first before you can GRANT permissions, roles or assign a
default ROLE.
eg.
since muna was given a role which contains CREATE TABLE PRIVILEDGE
We have to revoke permission from his role called c##managers as well.
Revoke succeeded.
eg.
revoke insert on emp from c##muna;
revoke update,delete on emp from c##muna;
desc dba_objects;
SQL> desc dba_objects;
Name Null? Type
----------------------------------------- --------
OWNER VARCHAR2(128)
OBJECT_NAME VARCHAR2(128)
SUBOBJECT_NAME VARCHAR2(128)
OBJECT_ID NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(23)
CREATED DATE
LAST_DDL_TIME DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)
NAMESPACE NUMBER
EDITION_NAME VARCHAR2(128)
SHARING VARCHAR2(18)
EDITIONABLE VARCHAR2(1)
ORACLE_MAINTAINED VARCHAR2(1)
APPLICATION VARCHAR2(1)
DEFAULT_COLLATION VARCHAR2(100)
DUPLICATED VARCHAR2(1)
SHARDED VARCHAR2(1)
CREATED_APPID NUMBER
CREATED_VSNID NUMBER
MODIFIED_APPID NUMBER
MODIFIED_VSNID NUMBER
select OWNER,
OBJECT_TYPE,
OBJECT_NAME,
STATUS
from dba_objects; ///
select OWNER
from dba_objects
where STATUS = 'INVALID'; /// to view all users with regards to objects
where status is invalid.
select OWNER,OBJECT_NAME
from dba_objects
where STATUS = 'INVALID';
select OWNER,OBJECT_NAME
from dba_objects
where OBJECT_TYPE = 'TABLE';
select USER
from dba_objects; /// to view all users with regards to objects.
-----------------------------------------------------------------------------------
------------------------------ --------
----------------------------------------------------------------------------
USERNAME
NOT NULL VARCHAR2(128)
USER_ID
NOT NULL NUMBER
PASSWORD
VARCHAR2(4000)
ACCOUNT_STATUS
NOT NULL VARCHAR2(32)
LOCK_DATE
DATE
EXPIRY_DATE
DATE
DEFAULT_TABLESPACE
NOT NULL VARCHAR2(30)
TEMPORARY_TABLESPACE
NOT NULL VARCHAR2(30)
LOCAL_TEMP_TABLESPACE
VARCHAR2(30)
CREATED
NOT NULL DATE
PROFILE
NOT NULL VARCHAR2(128)
INITIAL_RSRC_CONSUMER_GROUP
VARCHAR2(128)
EXTERNAL_NAME
VARCHAR2(4000)
PASSWORD_VERSIONS
VARCHAR2(17)
EDITIONS_ENABLED
VARCHAR2(1)
AUTHENTICATION_TYPE
VARCHAR2(8)
PROXY_ONLY_CONNECT
VARCHAR2(1)
COMMON
VARCHAR2(3)
LAST_LOGIN
TIMESTAMP(9) WITH TIME ZONE
ORACLE_MAINTAINED
VARCHAR2(1)
INHERITED
VARCHAR2(3)
DEFAULT_COLLATION
VARCHAR2(100)
IMPLICIT
VARCHAR2(3)
ALL_SHARD
VARCHAR2(3)
---------------------------------
to see active user from DB.
select user from dual;
resource_parameters
SESSIONS_PER_USER
Specify the number of concurrent sessions to which you want to limit the user.
CPU_PER_SESSION
Specify the CPU time limit for a session, expressed in hundredth of seconds.
CPU_PER_CALL
Specify the CPU time limit for a call (a parse, execute, or fetch), expressed in
hundredths of seconds.
CONNECT_TIME
Specify the total elapsed time limit for a session, expressed in minutes.
IDLE_TIME
Specify the permitted periods of continuous inactive time during a session,
expressed in minutes. Long-running queries and other operations are not subject to
this limit.
LOGICAL_READS_PER_SESSION
Specify the permitted number of data blocks read in a session, including blocks
read from memory and disk.
LOGICAL_READS_PER_CALL
Specify the permitted number of data blocks read for a call to process a SQL
statement (a parse, execute, or fetch).
PRIVATE_SGA
Specify the amount of private space a session can allocate in the shared pool of
the system global area (SGA). Refer to size_clause for information on that clause.
create profile
c##appl_profilee
limit
sessions_per_user 2 --
cpu_per_session 10000 -- hunderth of seconds
cpu_per_call 1 -- hunderth of seconds
connect_time unlimited -- minutes
idle_time 30 -- minutes
logical_reads_per_session default -- db blocks
logical_reads_per_call default -- db blocks
-- composite_limit default --
private_sga 20M --
failed_login_attempts 3 --
password_life_time 30 -- days
password_reuse_time 12 --
password_reuse_max unlimited --
password_lock_time default -- days
password_grace_time 2 -- days
password_verify_function null;
User altered.
----------------------------------------------
ALTER PROFILE c##DEFAULT LIMIT
FAILED_LOGIN_ATTEMPTS 3
PASSWORD_LIFE_TIME UNLIMITED;
========================================================
logical storage.
you reserve a particular amount of storage from the internal HDD for sdpecial
purpose.
you cann not phyisically control this reserved storage.
create tablespace
users
datafile
�/ora01/oracle/product/10.1.0/oradata/booktst_users_01.dbf�
size
50m;
create tablespace
procureofficer
datafile
'C:/app/clara/oradata/lab1.dbf'
size 50m;
Note that we used 50m to indicate that we wanted to create the tablespace
50 Megabytes in size. You can also use the K symbol for Kilobytes,
and the G symbol for Gigabytes. If you want to try to use the P symbol
for a 50 Petabyte tablespace,
////////////////----but you can only mention your path
create tablespace
myusers
datafile
'C:/oracle/product/10.1.0/oradata/booktst_users_01.dbf'
size 50m
--blocksize 3
--maxsize 100m
uniform size 10M
autoextend on
/
create tablespace
myusersss
datafile
'C:/oracle/product/10.1.0/oradata/admin/news.dbf'
size 50m
autoextend on
maxsize 100m
blocksize 32k
uniform size 10M
/
Maxsize: This is the maximum size that the datafile can grow.
We recommend creating a tablespace with maxsize unlimited to prevent a lock-up.
Size: This is the size of the underlying data file for the tablespace.
Uniform size: This specifies the size that the data file will grow when it
needs to extend.
viewing tablespace.
====