My computer is a Mac, I use Docker as a container, and I install Oracle 11g.

Users and tablespaces

1. Login and basic use

The system-level user has the sys system, which is more advanced than system. You must be a system administrator to log in to the system.

1. Open SQL-plus

$ sqlplus
Copy the code

2. Enter the user name and password

Here we can choose sys and system(the password is our own).

3. Switch to the sys user

$connect sys as sysdba;Copy the code

4. View the current user

$ show user;
Copy the code

5. View the data dictionary of the administrator information table

$ desc dba_users;
Copy the code

6. View existing users

$ select USERNAME from dba_users;
Copy the code

2. Import user Scott

1. Log in as sys first

$ sqlplus sys/oracle as sysdba;
Copy the code

2. Import and execute utlSAMpl.sql

SQL > @ / u01 / app/oracle/product / 11.2.0 / xe/RDBMS/admin/utlsampl SQLCopy the code

When you get something like the one above, it’s a success. If nothing is printed after the command is executed, chances are it didn’t work.

It then automatically exits SQLPlus.

3. Log in using Scott

$ sqlplus scott/tiger
Copy the code

4. View the current user

SQL> show user
USER is "SCOTT"
Copy the code

When you see USER is “SCOTT”, it’s ok, if it’s “USER is “”. The user is empty, this is a pit, because again Scott didn’t import successfully. (I’m very sorry that I didn’t make it clear myself, but I succeeded in confusion. You can refer to the following two articles.)

The Oracle Scott user does not exist

Oracle has no solution for Scott users under Docker

5. Check out our newly created user Scott

select USERNAME from dba_users
Copy the code

3, Check the tablespace

1. Query the tablespace as an administrator

Administrators can view dBA_TABLespaces. And user_tablespaces; A common user can view only user_TABLespaces.

Log in using system.

select TABLESPACE_NAME from dba_tablespaces;
Copy the code

select TABLESPACE_NAME from user_tablespaces;
Copy the code

In the following figure, we can see that oracle creates tablespaces for us by default.

dba_tablespaces
user_tablespaces

Administrators can view dba_users. And user_users; Common users can view only user_Users.

2. View default and temporary tablespaces

$ select default_tablespace, temporary_tablespace from dba_users where username = 'SYSTEM';
Copy the code

Create a new tablespace

In addition to the default five table Spaces, we can also create new table Spaces.

$ create tablespace matrix datafile 'matrix.dbf' size 256m;
Copy the code

Alter default tablespaces