資料定義語言ddl
--建立表
create
table customer
( id varchar2(40)
primary
keynot
null
, create_time date
, mobile varchar2(40)
, syscode varchar2(10)
);--注釋
comment
ontable customer is
'資訊表'
;comment
oncolumn customer.id is
'id'
;comment
oncolumn customer.create_time is
'建立時間'
;comment
oncolumn customer.mobile is
'發起人手機號'
;comment
oncolumn customer.syscode is
'系統編碼'
;--索引
create
index mobile_index on customer(job_id)
;create
index create_index on customer(create_time)
;--建立序列
create sequence customer_seq //建立序列名稱
[increment by n]
//遞增的序列值是 n 如果 n 是正數就遞增,如果是負數就遞減 預設是 1
[start
with n]
//開始的值,遞增預設是 minvalue 遞減是 maxvalue
//最大值 不設定最大值(由機器決定),或 根據表字段的值範圍設定 maxvalue
//最小值 同上
//迴圈 cycle:達到最大值後,將從頭開始累加 /不迴圈 一直追加
;//分配並存入到記憶體中
commit
;建立序列時使用cache能提高效能,特別是在高併發的情況下對資料庫的效能提公升還是不錯的。
但是使用快取會有產生斷號的現象,如果你的業務要求序列產生的值必須是連續的,那就只能使用nocache了。
cache,它的用處是快取指定個數的序列值。比如你設定的 cache 是20,那麼在獲取 nextval 時,oracle 會直接從
cache 中取下乙個序列值,如果 cache 中快取的序列值沒有了(比如 cache 中的序列值用完了,或者被手工清空了),
那麼 oracle 會再次產生20個序列值,並放置 cache 中供使用,這樣有助於提高序列值的獲取速度。
資料操縱語言dml--插入資料
insert
into customer values
(customer_seq.nextval,sysdate,
'***'
,'***');
insert
into customer(id,mobile)
value
(customer_seq.nextval,
'***'
);
oracla 學習位址 oracle函式,sql語句整理積累
每天積累一點點,期待自己的進步 1.關於substr函式的用法和個人見解 substr string,start position,length 我理解為,擷取某個字串中的某些內容 舉例 20170208 只獲取年月也就是 201702 string引數為字串的意思,可以直接寫內容如 2017020...
SQL常用知識點積累
對於sql,主要是sql server的使用,常用知識點如下 1.根據資料庫指令碼生成資料庫。一般根據資料庫指令碼生成資料庫時,會非常慢,因為需要較資料庫架構即資料及其他資料庫相關的資訊一起複製到目標資料庫。但如果僅選擇資料庫指令碼的生成相關的表的sql語句,則較快。因此,根據指令碼還原資料庫時,一...
Sql 知識積累
複製個新錶,資料 結構 會進行複製,約束是不能進行複製的 select top 0 into 新錶的名稱 from 舊表的名稱 效率最高 top 獲取前多少行資料 select top 10 percent from 表的名稱 select distinct from 表的名稱 去除重複的資料,是對...