Oracle's complete process of creating tablespaces, users

Keywords: Oracle SQL

Oracle's complete process of creating tablespaces, users

I often use Oracle in my work and study process. Due to lack of experience and skills, Baidu is required every time.Now let's summarize how Oracle created users and share them with you.(
Here I will paste the sql statement directly. When using it, I can copy and paste it directly.

 /*
  Steps:
  1,Create a tablespace
  2,Create User
  3,User Authorization
  */

  /*Create a tablespace*/
  create tablespace QCJ_TABLESPACE
  /*Table Space Physical File Name*/
  datafile 'QCJ_TABLESPACE.dbf' 
  -- This specifies the physical file location of the tablespace
  -- datafile 'F:\APP\QIUCHANGJIN\ORADATA\ORCL\QCJ_TABLESPACE.dbf' 
  -- Size 50M,every time 5M Automatic increase, maximum unlimited
  size 50M autoextend on next 5M maxsize unlimited; 

   /* Create User*/
  create user qiuchangjin 
  IDENTIFIED BY root --User Password
  default tablespace QCJ_TABLESPACE-- The tablespace was created above
  temporary tablespace TEMP -- Temporary tablespace default TEMP
  profile DEFAULT;
  --password expire;
   /*Password expiration requires a password reset. This means that you will be prompted to re-enter your new password after the first login of an expired user with this newly created password. Otherwise, you will be rejected to log on. After resetting the new password, you can log on. The user's password is your new password, which is equivalent to the option of changing your password at first login.*/

   /* User Authorization_1*/
  grant connect,resource,dba to qiuchangjin;

   /* User Authorization_2*/
  grant connect to qiuchangjin with admin option;
  grant dba to qiuchangjin with admin option;
  grant resource to qiuchangjin with admin option;

  /*Query all tablespace physical locations*/
  select name from v$datafile;
  /*Query the tablespace of the current user*/
  select username,default_tablespace from user_users;
  /*Modify the user's default tablespace*/
  alter user User name default tablespace New tablespace; 
  /*Query all tablespaces*/
  select * from user_tablespaces; 

  /* Delete tablespace*/
  alter tablespace QCJ_TABLESPACE offline;
  drop tablespace QCJ_TABLESPACE including contents and datafiles;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • View current user information:

1. View role privilege information owned by the current user:

select * from role_sys_privs;
  • 1

2. View the details of the current user:

select * from user_users;
  • 1

3. View the role information of the current user:

select * from user_role_privs;
  • 1
  • Set Oracle user password to unlimited
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
  • 1

Posted by bharrison89 on Fri, 26 Jun 2020 09:23:12 -0700