自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

DB2表管理語句

數(shù)據(jù)庫
數(shù)據(jù)庫中,表的重要性毋庸置疑,這是數(shù)據(jù)庫系統(tǒng)最基礎(chǔ)的部分。下面就為您介紹DB2中表管理要用到的相關(guān)語句,供您參考。

DB2表管理的相關(guān)語句是學習DB2數(shù)據(jù)庫系統(tǒng)的基礎(chǔ)知識,下面就為您詳細介紹一些DB2表管理語句,希望對您學習DB2表管理方面能有所幫助。

創(chuàng)建表

CREATE TABLE BOOKS
( BOOKID INTEGER,
BOOKNAME VARCHAR(100),
ISBN CHAR(10) )

使用like創(chuàng)建表
CREATE TABLE MYBOOKS LIKE BOOKS

制定表空間
db2 create table T1 (c1 int ...) in TS1
db2 create table T2 (c1 float ...) in TS1

刪除表
drop table tab_name

添加刪除列
db2 => create table test (c1 int)
DB20000I The SQL command completed successfully.
db2 => alter table test add c2 char(8)
DB20000I The SQL command completed successfully.
db2 => alter table test drop c2  
DB20000I The SQL command completed successfully.

列的修改及限制
1.修改長度
alter table tab_name alter c1 set data type varchar(20)
2.設(shè)置為非空
alter table tab_name alter c1 set not null
create table tab_name (id interger not null)
3.設(shè)置默認值
create table tab_name (id integer,name varchar(10) with default 'none')
4.為列創(chuàng)建序列
使用關(guān)鍵字 generated always as identity
create table tab_name (id integer generated always as identity (start with 1,increment by 1))
5.唯一性約束
使用關(guān)鍵字primary key
create table tab_name (id int not null primary key)
使用關(guān)鍵字unique
alter table tab_name add constraint unique (id)
create unique index idx_name on tab_name (id)
6.檢查性約束
使用關(guān)鍵字check
ALTER TABLE BOOKS ADD BOOKTYPE CHAR(1) CHECK (BOOKTYPE IN ('F','N') )
7.參照約束
使用關(guān)鍵字references
CREATE TABLE AUTHORS (AUTHORID INTEGER NOT NULL PRIMARY KEY,
                      LNAME VARCHAR(100),
                      FNAME VARCHAR(100))
CREATE TABLE BOOKS (BOOKID INTEGER NOT NULL PRIMARY KEY,
                    BOOKNAME VARCHAR(100),
                    ISBN CHAR(10),
                    AUTHORID INTEGER REFERENCES AUTHORS)
 

 

 

【編輯推薦】

DB2環(huán)境變量管理的策略選擇

幾個簡單的DB2操作語句

DB2隔離級別之讀穩(wěn)定性

DB2系統(tǒng)目錄視圖安全上的隱患

DB2信息目錄中心簡介

責任編輯:段燃 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2010-09-30 10:53:39

DB2表管理

2010-11-01 12:11:43

DB2表空間

2010-11-03 15:49:32

DB2刪除表

2010-09-30 11:55:03

DB2表空間

2010-09-01 14:46:16

DB2表空間

2010-09-06 15:13:05

DB2

2010-11-04 15:39:40

DB2 SQL語句

2010-11-04 11:17:42

DB2 Merge語句

2010-11-01 14:46:41

DB2更新語句

2010-11-03 15:35:27

DB2修改表

2010-09-01 10:38:47

DB2統(tǒng)計信息

2010-11-01 16:07:22

DB2表空間

2010-09-30 16:46:11

DB2操作語句

2010-11-04 11:39:47

2010-08-31 17:14:24

DB2表空間

2010-09-01 11:46:01

DB2臨時表SQL

2010-11-04 11:07:56

DB2管理命令

2010-11-02 14:45:12

DB2創(chuàng)建表空間

2010-11-01 16:38:13

DB2表空間

2010-11-01 16:44:43

DB2表空間
點贊
收藏

51CTO技術(shù)棧公眾號