Oracle database SQL (structured query statement) detailed classification and usage examples (for tables)

1) DDL (Data Definition Language) data definition language

a.create

创建表:create table tname(colName1 Datatype,coluName2 Datatype,……);

Description: This keyword can not only be used to create a table, but also can be used to operate, sequence (sequence), view (view), index (index)

b.alter

Modify the table structure:

  1. Add table fields: alter table tName add (colName Datatype);
  2. Delete table fields: alter table tName drop column colName;
  3. Modify the field name of the table: alter table tName rename oldName to newName;
  4. Modify the field type of the table: alter table tName modify colName Datatype;

c.truncate

Clear the data in the table but keep the table structure:

truncate table tName;

d.drop

Delete table structure:

drop table tName;

Description: This keyword can not only delete tables, but also delete indexes, sequences, views, stored procedures, functions, and triggers. The usage is similar .

2) DML (Data Manipulation Language): Data Manipulation Language

a.insert

Insert data: insert into tName(colName1, colName2,...) values(value1, value2,...)

Description: Insert data in all tables, tName (the fields in the table can be written later)

b.update

Modify data: update tName set colName1 = value, colName2 = value, ... where condition

c.delete

Delete data: delete from tName where Condition 
description: when no conditions are added, delete all data in the table, the function is similar to truncate

3) DQL (Data Query Language): Data Query Language

select

Query data: select * from tName where condition

Description: query all data without writing conditions, * is a wildcard to indicate all fields, and you can also write specific field names in the table

4) TCL (Transaction Control Language): Transaction Control Language

a.commit: data submission

can be used directly

b.rollback: data rollback

can be used directly

c.savepoint: save the restore point

can be used directly

5) DCL (Data Control Language): Data Control Language

a.grant authorization operation

The right to create views for ordinary users: grant create view to username

b.revoke revoke permission

Revoke the user's right to create a view: revoke create view from username

c.create userCreate a user

create user username identified by password;

Description: The user name needs to be in English, and the password must be numbers or letters or English symbols or combinations

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325502181&siteId=291194637