Oracle syntax (1: table space, create user, grant permissions)

0. Oracle's SQL command classification

  1. DDL: Create table, create user create/drop/alter/show
  2. DML: add/delete/update operation insert/delete/update
  3. DQL: query select
  4. DCL: permission control grant/revoke

1. Create and delete tablespaces

Create a table space:
create tablespace tablespace name
datafile'file name.dbf' Specify the table space file name, you can specify the specific location, such as:'d:/xxx.dbf' defaults to this directory: c:\oracle\product\10.2.0\db_1\database
size initial size The hard disk space occupied by the table space at the beginning, the unit can be K or M
autoextend on If the initial size specified above is used up, automatic expansion is turned on
-- 创建表空间space1,数据文件为space1.dbf,初始大小为20M,空间不足自动扩展。
create tablespace space1 datafile 'space1.dbf' size 20m autoextend on;

-- 创建表空间space2,数据文件为space2.dbf,初始大小为500k
create tablespace space2 datafile 'space2.dbf' size 500k;
Delete the table space:
drop tablespace table space name
[including contents and datafiles] Delete all the contents and physical files in the table space
-- 删除space2表空间,同时删除内容和文件
drop tablespace space2 including contents and datafiles;

2. Create users and give user permissions

Create user:
create user username
identified by Specify password
default tablespace Specify the table space used by the current user, if not specified, the USERS table space is used by default
-- 创建用户user1,密码orcl,指定默认表空间为space1
create user user1 identified by orcl default tablespace space1;

Granted permission:

grant role to username

-- 进入 system 用户下给用户user1赋予 dba权限
grant dba to user1;

Three roles in Oracle: connect, resource, dba

Insert picture description here
Insert picture description here

  • DBA role: Has all privileges and is the highest authority of the system. Only the DBA can create the database structure, and the system authority also needs to be granted by the DBA, and the DBA
    user can operate any base table of all users, including deletion. Such as: system

Guess you like

Origin blog.csdn.net/RookiexiaoMu_a/article/details/105127740