達夢資料庫常用SQL

2021-10-11 13:31:09 字數 2626 閱讀 8315

--達夢資料庫建立表

create

table test_table(

scid varchar2(10)

primary

key,

scname varchar2(20)

,

scsm number(6)

,

scprice number(4,

2));

---------------------當前使用者--------------------------

--達夢資料庫-獲取當前使用者擁有的表

select table_name from user_tables;

--達夢資料庫-獲取當前使用者所屬的某個表的字段

select

*from user_tab_columns where table_name=

'表名'

;--達夢資料庫-獲取當前使用者某個表的注釋

select

*from user_tab_comments where table_name=

'表名'

;--達夢資料庫-獲取當前使用者某個表某個欄位的注釋

select

*from user_col_comments where table_name=

'表名'

where column_name=

'欄位名'

;---------------------所有使用者(不包括系統表)--------------------------

--達夢資料庫-所有使用者的表(單獨判斷某個表是否存在,要加owner條件)(不包括系統表)

select table_name from all_tables;

--達夢資料庫-獲取所有使用者所屬的某個表的字段(不包括系統表)

select

*from all_tab_columns where table_name=

'表名'

;--達夢資料庫-獲取所有使用者所屬的某個表的注釋(不包括系統表)

select

*from all_tab_comments where table_name=

'表名'

;--達夢資料庫-獲取所有使用者某個表某個欄位的注釋(不包括系統表)

select

*from all_col_comments where table_name=

'表名'

where column_name=

'欄位名'

;---------------------所有使用者(包括系統表)--------------------------

--達夢資料庫-所有使用者的表,包括(包括系統表)(單獨判斷某個表是否存在,要加owner條件)

select table_name from dba_tables;

--達夢資料庫-獲取所有使用者所屬的某個表(包括系統表)的字段

select

*from dba_tab_columns where table_name=

'表名'

;--達夢資料庫-獲取所有使用者所屬的某個表(包括系統表)的注釋

select

*from dba_tab_comments where table_name=

'表名'

;--達夢資料庫-獲取所有使用者某個表某個欄位的注釋(包括系統表)

select

*from dba_col_comments where table_name=

'表名'

where column_name=

'欄位名'

;--達夢資料庫-新增字段

alter

table 表名 add 欄位名 varchar(15

);--達夢資料庫-修改字段長度

alter

table 表名 modify 欄位名 varchar(60

);--達夢資料庫-修改表名

alter

table 表名 rename

to 新錶名;

--達夢資料庫-修改欄位名稱

alter

table 表名 rename

column 欄位名 to 新欄位名;

--達夢資料庫-修改表的注釋

comment

ontable 表名 is

'表注釋內容'

;--達夢資料庫-修改欄位的注釋

comment

oncolumn 表名.欄位名 is

'字段注釋內容'

;--達夢資料庫-刪除表的字段

alter

table 表名 drop 欄位名 cascade

;--達夢資料庫-獲取資料表所有字段,以逗號分隔--

select listagg(column_name,

',')

within

group

(order

by column_id)

from user_tab_cols where table_name=

'test_table'

;

還有一些沒有補充,比方說建立索引之類的,後面有空再說吧

達夢資料庫常用sql語句整理(1)

select from v tablespace 2.hmain 表空間檢視語句 select from v huge tablespace 3.檢視使用者占用的空間 使用系統函式 user used space 得到使用者占用空間的大小,函式引數為使用者名稱,返回值為占用的頁的數目。select ...

達夢資料查詢編碼 達夢常用sql

1 檢視儲存過程建立指令碼 select text from dba source where owner and type proc 注 owner是指使用者名稱,type可以檢視型別 比如檢視 建表等。2 檢視表的儲存大小 select segment name,bytes 1024 1024 ...

國產達夢資料庫常用記錄

命令 disql conn 輸入賬號密碼 示例語句 create table dmhr.address addressid int identity 1,1 primary key,address1 varchar 60 not null,address2 varchar 60 city varch...