declare viewExist number
begin
select count(1) into viewExist from user_views where VIEW_NAME='REPORT_APPOINTMENTSBYLOCATORS'
if viewExist=0 then
execute immediate
'CREATE VIEW REPORT_APPOINTMENTSBYLOCATORS
AS
SELECTappointmentID, startDateTime, endDateTime, grid, locator,
meetingAddress, contactNumber, company, contact, reasonForAppointment,
DtFirstCall, DtSecondCall,CustomerAnswerFirstCall, CustomerAnswerSecondCall,
IsMeetOnSite, DtLastModified, AppointmentStatus, IsLocatorArriveOnsite,
DtCompletedAt,DtLocatorArriveOnsite, RescheduledOn, RescheduledAt, IsRescheduled, city
FROM Appointment'
end if
end
方法一:直接在表中指定字段类型为serial 类型
david=# create table tbl_xulie (david(# id serial,
david(# name text)
NOTICE: CREATE TABLE will create implicit sequence "tbl_xulie_id_seq" for serial column "tbl_xulie.id"
CREATE TABLE
david=#
方法二:先创建序列名称,然后在新建的表中列属性指定序列就可以了,该列需int 类型
创建序列的语法:
CREATE [ TEMPORARY | TEMP ] SEQUENCE name [ INCREMENT [ BY ] increment ][ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ]
[ START [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ]
[ OWNED BY { table.column | NONE } ]
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)