日期和時間類型
-
date
: 'yyyy-mm-dd' -
time
: 'HH-MM-SS'-
time with timezone
: 保存時區(qū)信息
-
-
timestamp
: 'yyyy-mm-dd HH-MM-SS.mmtimestamp with timezone
-
cast string as t
:將以符合格式的字符串string
轉(zhuǎn)化為t
類型(t
可以為time
,date
,timestamp
) -
extract(field from d)
:從time
或date
值d
中提取出單獨(dú)域(field
可以為year
,month
,day
,hour
,minute
,second
,timezone_hour
,timezone_minute
)
默認(rèn)值
create table student(
ID varchar(5) primary key,
name varchar(20) not null,
dept_name varchar(20),
tot_cred numeric(3, 0) default 0);
創(chuàng)建索引
索引:創(chuàng)建在關(guān)系的屬性上的一種數(shù)據(jù)結(jié)構(gòu),允許數(shù)據(jù)庫系統(tǒng)高效地找到關(guān)系中那些在索引屬性上取得給定值的元組,而不需要掃描關(guān)系中的所有元組。
create index studentID_index on student(ID);
大對象類型
-
clob
:字符數(shù)據(jù)的大對象類型(character-large-object
) -
blob
:二進(jìn)制數(shù)據(jù)的大對象類型(binary-large-object
)
create table my_files(
book_review clob(10KB),
image blob(10MB),
movie blob(2GB)
);
create table
拓展
- 創(chuàng)建與現(xiàn)有表模式相同的表
create table temp_instructor like instructor;
- 將查詢結(jié)果寫入新表
create table t1 as (
select *
from instructor
where dept_name = 'Music')
with data;