資料庫常用操作DDL和DCL

2021-10-08 03:58:35 字數 810 閱讀 7742

主要是常用的新增注釋,修改表名稱等簡單操作

新增表注釋:

comment on table 表名 is '個人資訊';

新增字段注釋:

comment on column 表名.列名 is '姓名';

alter table tpssprod.cr_rule_level add (attr_name varchar2(256));

給使用者加許可權

grant select,insert,update,delete on 表名 to 使用者名稱;

-- 修改表名稱

alter table trans_source_date rename to trans_source_date_bak20191030;

-- 備份資料庫

create table trans_source_date_bak_1031 as select * from trans_source_date;

1、建立索引

create index 索引名 on 表名(列名);

2、刪除索引

drop index 索引名;

3、建立組合索引

create index 索引名 on 表名(列名1,,列名2);

-- create sequence 建立序列

create sequence seq_o_order_id

minvalue 1

maxvalue 999999999999999

start with 3906

increment by 1

cache 20

資料庫DDL操作

ddl 1.資料庫操作 檢視所有資料庫 show databases 切換 選擇要操作的 資料庫 use 資料庫名 建立資料庫 create database if not exists mydb1 charset utf8 刪除資料庫 drop database if exists mydb1 修...

資料庫 DDL 和 DML操作

目錄 一 ddl操作 1.運算元據庫 2.運算元據庫表 二 dml操作 1.insert 2.delete 3.update create database if not exists dbname 建立資料庫 drop databasae if exists dbname 銷毀資料庫 2.1 新增...

資料庫DDL DML和DCL

資料操縱語言dml 最為常用,用來對資料庫裡的資料進行操作的語言。它們是select update insert delete 增 刪 改 查 資料定義語言ddl 資料定義功能,它定義資料庫的邏輯結構,主要的命令有create alter drop等,ddl主要是用在定義或改變表 table 的結構...