1 show variables like 'version' 查看版本
2
3 1:
4 DELIMITER $$ 开始 $$ DELIMITER 结束 其实就是告诉mysql解释器,该段命令是否已经结束了,mysql是否可以执行了。
5 默认情况下,delimiter是分号;。
6
7 2:创建表:
8
9 创建表:
10 CREATE TABLE tb_student (
11 id INT PRIMARY KEY auto_increment, //主键约束,自动增长
12 NAME VARCHAR (18) NOT NULL, //非空约束
13 sex VARCHAR (2) check(sex = '男' or sex ='女'),
14 age INT CHECK (age>18 AND age<60), //检查约束
15 address VARCHAR (200),
16 email VARCHAR (200) UNIQUE, //唯一约束
17 tb_id int,
18 //外键约束, 自己的表名(自己的外键) REFERENCES 外部表名(字段)
19 //CONSTRAINT FOREIGN KEY 外键名【表名+约束】(外键) REFERENCES 主表(字段)
20 CONSTRAINT foreign KEY tb_student_fk(tb_id) REFERENCES tb_demp(id)
21 )
22
23 //建表之后添加外键约束
24 ALTER TABLE tb_student
25 ADD CONSTRAINT foreign KEY tb_student_fk(tb_id) REFERENCES tb_temp(id)
26
27 //设置自动增长
28 alter table tb_student
29 modify column id int auto_increment
30
31
32 mysql:
33 DROP TABLE IF EXISTS Privilege; 删除表如果有,mysql判断存在不存在 用法:
34 1,drop table\view\function\.. if exists 名称
35 2, if exists(select * from ...) then end if
36 3,mysql判断表是否存在:
37 if EXISTS (select 1 from `INFORMATION_SCHEMA`.`TABLES` WHERE table_name ='AdvMaterial' and TABLE_SCHEMA=database())
38 database() :获取当前数据库的名称
39 4:if (SELECT COUNT(*) FROM AdvMaterial) = NULL 判断记录是否为空,是空则不存在,但是括号中如果没有这张表则会报错
40
41 CREATE TABLE Privilege(
42 PL_nPrivilegeID int NOT NULL,
43 PL_strDescription varchar(80) NOT NULL,
44 PL_nObjectID int NOT NULL DEFAULT 0,
45 PL_nObjectStatusID int NOT NULL DEFAULT 0,
46 PL_nOperationID int NOT NULL DEFAULT 0,
47 PL_nScope int NOT NULL DEFAULT 0,
48 PL_nParentOperation int NULL,
49 PL_nFunctionClass int NOT NULL DEFAULT 0,
50 CONSTRAINT PK_Privilage PRIMARY KEY CLUSTERED
51 (
52 PL_nPrivilegeID ASC
53 )
54 );
55
56 创建表的知识点:
57 1,默认0约束,default 0 ,不为空 not null
58 2,主键:primary key asc 是递增,desc 是递减, PRIMARY KEY CLUSTERED 主键索引 ,CONSTRAINT约束
59 3,FT_nTemplateID int IDENTITY(1,1) NOT NULL, 列3,FT_nTemplateID int类型 自动增长,每次增加1,不为空
60 IDENTITY(1,1) 写为mysql是:
61 FT_nTemplateID int AUTO_INCREMENT NOT NULL, mysql默认每次增加1
62 4,declare Mon int; declare 申明 Mon 是int类型 sqlserver中直接把[],@等删掉 declare @pubdate datetime declare pubdate datetime
63 5,删除:
64 delete PubInsertionDefine where PID_nPublicationID=@publicationid and PID_dtInsertion between @begindate and @enddate //sqlserver
65 delete PubInsertionDefine FROM PubInsertionDefine where PID_nPublicationID=publicationid and PID_dtInsertion between begindate and enddate; //mysql
66
67 -------------------------------------------------------------------------------------------------------------------------------------------------------
68 触发器区别:
69 1,mysql不能这样写 AFTER INSERT, UPDATE,不能after后面两个修改的操作
70 mysql触发器用法:
71 create trigger 触发器名称 on 表名 after insert/update for each row
72 begin
73 ...
74 end;
75 2, select @pubdate=@pubdate+1 == set pubdate=pubdate+1
76
77 有定义declare就要有begin end
78
79 sqlserver:
80 CREATE TRIGGER tri_PubDateInsert
81 ON PubDate AFTER INSERT, UPDATE
82 AS
83 BEGIN
84 declare @pubdate datetime
85 declare @publicationid int
86 declare @begindate datetime
87 declare @enddate datetime
88 declare @Mon int
89 declare @Tues int
90 declare @Wed int
91 declare @Thur int
92 declare @Fri int
93 declare @Sat int
94 declare @Sun int
95 declare @wday int
96 declare @delete int
97 select @publicationid=E_PDID, @begindate=E_BeginDate, @enddate=E_EndDate,
98 @Mon=E_Mon, @Tues=E_Tues, @Wed=E_Wed, @Thur=E_Thur, @Fri=E_Fri, @Sat=E_Sat, @Sun=E_Sun, @delete=SYS_DELETEFLAG
99 from INSERTED
100 delete PubInsertionDefine where PID_nPublicationID=@publicationid and PID_dtInsertion between @begindate and @enddate
101 select @pubdate=@begindate
102 if @delete=0
103 while @pubdate<=@enddate
104 begin
105 select @wday=datepart(weekday,@pubdate)
106 if (@wday=1 and @Sun=1) or (@wday=2 and @Mon=1) or (@wday=3 and @Tues=1) or (@wday=4 and @Wed=1) or
107 (@wday=5 and @Thur=1) or (@wday=6 and @Fri=1) or (@wday=7 and @Sat=1)
108 insert PubInsertionDefine values (@publicationid,@pubdate,'系统自动插')
109 select @pubdate=@pubdate+1
110 end
111 END;
112
113 mysql:
114 DROP TRIGGER IF EXISTS `tri_PubDateInsert`;
115 CREATE TRIGGER tri_PubDateInsert AFTER INSERT
116 ON PubDate
117 FOR EACH ROW
118 BEGIN
119 declare pubdate datetime;
120 declare publicationid int;
121 declare begindate datetime;
122 declare enddate datetime;
123 declare Mon int;
124 declare Tues int;
125 declare Wed int;
126 declare Thur int;
127 declare Fri int;
128 declare Sat int;
129 declare Sun int;
130 declare wday int;
131 declare deletee int;
132 SET publicationid=E_PDID, begindate=E_BeginDate, enddate=E_EndDate,
133 Mon=E_Mon, Tues=E_Tues, Wed=E_Wed, Thur=E_Thur, Fri=E_Fri, Sat=E_Sat, Sun=E_Sun, deletee=SYS_DELETEFLAG;
134 delete PubInsertionDefine FROM PubInsertionDefine where PID_nPublicationID=publicationid and PID_dtInsertion between begindate and enddate;
135 SET pubdate=begindate;
136 if deletee=0 AND pubdate<=enddate
137 then set wday=datepart(weekday,pubdate);
138 end if;
139
140 if (wday=1 and Sun=1) or (wday=2 and Mon=1) or (wday=3 and Tues=1) or (wday=4 and Wed=1) or
141 (wday=5 and Thur=1) or (wday=6 and Fri=1) or (wday=7 and Sat=1)
142 then insert PubInsertionDefine values (publicationid,pubdate,'系统自动插');
143 end if;
144 set pubdate=pubdate+1;
145 END;
146
147
148 -----------------------------------------------------------------------------------------------------------------------------------------------------
149 视图的区别:
150 mysql 视图的用法:create view 视图名 as select ..from .. where ...
151 条件判断语句 case when:
152
153 1,
154 IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[AdDocument]'))
155 DROP VIEW [dbo].[AdDocument]; //判断是否有AdDocument这个视图,如果有就删除
156 mysql: DROP VIEW if EXISTS AdDocument;
157
158 2,
159 其中:
160 convert(float,AI_PagePointX) 在msyql中convert 用法与sqlserver中正好相反 convert(float,AI_PagePointX) 变成convert(AI_PagePointX,DECIMAL)
161 数据类型有几种不一样,分别是:decimal signed varchar 对应int float money char 等类型
162 sqlserver:
163 IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[PubDetail]'))
164 EXEC dbo.sp_executesql @statement = N'create view [dbo].[PubDetail] as
165 select SYS_DOCUMENTID PD_nDetailID, AI_InnerPageName PD_strPageName,
166 convert(float,AI_PagePointX) PD_fPosX, convert(float,AI_PagePointY) PD_fPosY, case AI_IfFigSign when 1 then ''y'' else ''n'' end PD_bFigSign
167 from AdvItem
168 where SYS_DELETEFLAG=0';
169 mysql:
170 DROP VIEW if EXISTS PubDetail ;
171 create view PubDetail as
172 select SYS_DOCUMENTID PD_nDetailID, AI_InnerPageName PD_strPageName,
173 convert(AI_PagePointX,DECIMAL) as PD_fPosX, convert(AI_PagePointY,DECIMAL) as PD_fPosY,
174 case when AI_IfFigSign = 1 then "y" else "n" end PD_bFigSign
175 from AdvItem
176 where SYS_DELETEFLAG=0 ;
177
178 ------------------------------------
179 3, ''n'',''y'' 变成 "n" :
180
181 IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[AdItem]'))
182 EXEC dbo.sp_executesql @statement = N'CREATE view [dbo].[AdItem] as
183 select SYS_DOCUMENTID AI_nAdItemID, AI_OrderID AI_nOrderNo, case AI_IfFigSign when 0 then ''n'' else ''y'' end AI_cIfFigSign,
184 AI_PublishTime AI_dtPublishTime, ''y'' AI_cIfValid, AI_FlowReviseStatus+1 AI_nLockStatus,
185 AI_Publication_ID AI_nPublicationID, AI_Edition_ID AI_nEditionID, AI_TradeID AI_nAdCategoryID,
186 AI_ArticleID AI_nDocumentID, AI_PayMode_ID AI_nPayingCategory, convert(money,AI_AmountReceivable) AI_mAccountReceivable,
187 convert(money,AI_AmountReceived) AI_mPayment, AI_Memo AI_strMemo, ''n'' AI_cIfChecked, 0 AI_nIfExam, AI_Brand_ID AI_nBrandID,
188 AI_Customer_ID AI_nPayerID, case AI_IfCanceled when 0 then ''n'' else ''y'' end AI_cIfCanceled,
189 AI_AdType_ID AI_nAdTypeID, AI_Field_ID AI_nFieldID, AI_PubMemo AI_strPubMemo, AI_PageName AI_strPageName
190 from AdvItem
191 where SYS_DELETEFLAG=0';
192
193 DROP VIEW if EXISTS AdItem ;
194 create view AdItem as
195 select SYS_DOCUMENTID AI_nAdItemID, AI_OrderID AI_nOrderNo, case AI_IfFigSign when 0 then "n" else "y" end AI_cIfFigSign,
196 AI_PublishTime AI_dtPublishTime, "y" AI_cIfValid, AI_FlowReviseStatus+1 AI_nLockStatus,
197 AI_Publication_ID AI_nPublicationID, AI_Edition_ID AI_nEditionID, AI_TradeID AI_nAdCategoryID,
198 AI_ArticleID AI_nDocumentID, AI_PayMode_ID AI_nPayingCategory, convert(AI_AmountReceivable,DECIMAL) AI_mAccountReceivable,
199 convert(AI_AmountReceived,DECIMAL) AI_mPayment, AI_Memo AI_strMemo, "n" AI_cIfChecked, 0 AI_nIfExam, AI_Brand_ID AI_nBrandID,
200 AI_Customer_ID AI_nPayerID, case AI_IfCanceled when 0 then "n" else "y" end AI_cIfCanceled,
201 AI_AdType_ID AI_nAdTypeID, AI_Field_ID AI_nFieldID, AI_PubMemo AI_strPubMemo, AI_PageName AI_strPageName
202 from AdvItem
203 where SYS_DELETEFLAG=0;
204
205
206 ---------------------------------------------------------------------------------------------------------------------------------
207 PROCEDURE 过程的区别:
208 mysql不支持返回表,可以用其他方法代替,如临时表
209
210 游标:
211 select 要放在declare下面,
212 qxCursor;游标的用法,如下:
213
214 sqlserver:
215 CREATE PROCEDURE [dbo].[usp_CheckUserPrivilege]
216 @strUserID varchar(16), @nPrivilegeId INT AS
217 DECLARE @strName varchar(32)
218 DECLARE @chOk char(1)
219 SELECT @strName=user_strName FROM Users
220 WHERE user_strLoginName = @strUserID
221 declare @str varchar(255)
222 declare qxCursor cursor for
223 select NRESOURCEID from FSYS_PERMISSION, FSYS_ROLEUSERRELATIONS
224 where NID=ROLEID
225 and NRESOURCETYPE='ADV_FIGOUT'
226 and USERCODE=@strUserID
227 open qxCursor
228 fetch next from qxCursor into @str
229 while (@@FETCH_STATUS <> -1)
230 begin
231 IF EXISTS (select * from dbo.ufn_SplitToTable(@str) where n=@nPrivilegeId)
232 BEGIN
233 SELECT @chOk='Y'
234 break
235 END
236 ELSE
237 SELECT @chOk='N'
238 fetch next from qxCursor into @str
239 end
240 close qxCursor
241 deallocate qxCursor
242 IF @strName is NULL
243 SELECT @chOk='F'
244 SELECT @strName, @chOk;
245 mysql:
246
247 while 的用法:
248 while do
249 end while
250
251 if:用法
252 if then;
253 else
254
255 end if
256
257 while 例子:
258 DROP PROCEDURE if EXISTS test_while;
259 CREATE PROCEDURE test_while(in in_count INT)
260 BEGIN
261 DECLARE count int DEFAULT 0;
262 WHILE count<10 do
263 set count = count +1;
264 end WHILE;
265 SELECT count;
266 END
267
268 exg:
269 DROP PROCEDURE IF EXISTS usp_CheckUserPrivilege;
270 CREATE PROCEDURE usp_CheckUserPrivilege
271 (
272 strUserID varchar(16), nPrivilegeId INT
273 )
274 BEGIN
275 DECLARE strName varchar(32);
276 DECLARE chOk char(1);
277
278 declare str varchar(255);
279 declare qxCursor cursor for 申明一个游标
280 select NRESOURCEID from FSYS_PERMISSION, FSYS_ROLEUSERRELATIONS
281 where NID=ROLEID
282 and NRESOURCETYPE='ADV_FIGOUT'
283 and USERCODE=strUserID;
284 SELECT strName=user_strName FROM Users
285 WHERE user_strLoginName = strUserID;
286
287 open qxCursor; 打开
288 READ_loop:LOOP 开始遍历
289 fetch next from qxCursor into str;
290 while (FETCH_STATUS <> -1) DO
291 IF ( EXISTS (select * from ufn_SplitToTable where n=nPrivilegeId)) -- ---ufn_SplitToTable(这个方法未完成,返回表),ufn_SplitToTable(str),参数没有传str
292 THEN
293
294 SELECT chOk='Y' ;
295 ELSE
296 SELECT chOk='N';
297 END IF;
298 FETCH next FROM qxCursor into str;
299 END WHILE;
300 END LOOP; 关闭
301 -- close qxCursor;
302 -- deallocate qxCursor
303 IF strName is NULL
304 THEN
305 SELECT chOk='F' ;
306 SELECT strName, chOk;
307 END IF;
308 END;
309 ------------------------------------------
310 临时表:(3,usp_CopyReserve)
311
312 直接将查询结果导入临时表
313 CREATE TEMPORARY TABLE tempresv AS SELECT * FROM FigReserve;
314 truncate TABLE tmpTable; -- 使用前先清空临时表。
315 ltrim(AI_ArticleID), 去掉左边空格字符
316
317 临时表实例:
318 CREATE PROCEDURE sp_test_tt(IN i_chars VARCHAR(50),OUT o_counts BIGINT)
319 BEGIN
320 create temporary table if not exists tmpTable
321 (
322 objChk varchar(255) primary key,
323 ModelName varchar(50),
324 Operator varchar(500),
325 PModelName varchar(50)
326 );
327 truncate TABLE tmpTable; -- 使用前先清空临时表。
328
329 insert into tmpTable values(i_chars,i_chars,i_chars,i_chars);
330 insert into tmpTable values(i_chars,i_chars,i_chars,i_chars); -- 语句1
331 select * from tmpTable; -- 语句2
332 select count(*) into o_counts from tmpTable; -- 语句3
333 END;
334
335
336 sqlserver:
337 CREATE PROCEDURE [dbo].[usp_CopyReserve]
338 @nPubMask INT, @nGridID INT,@nEditionID INT,
339 @strOldDay VARCHAR(16), @strNewDay VARCHAR(16) AS
340 SELECT * INTO #tempresv FROM FigReserve
341 WHERE
342 FigReserve.FR_dtPubDate = @strOldDay and
343 FigReserve.FR_nPubMask = @nPubMask and
344 FigReserve.FR_nGridID = @nGridID and
345 FigReserve.FR_nEditionMask = @nEditionID
346 UPDATE #tempresv
347 SET FR_dtPubDate=@strNewDay
348 INSERT INTO FigReserve
349 SELECT * FROM #tempresv;
350 mysql:
351 DROP PROCEDURE IF EXISTS usp_CopyReserve;
352 CREATE PROCEDURE usp_CopyReserve
353 (
354 nPubMask INT, nGridID INT,nEditionID INT,
355 strOldDay VARCHAR(16), strNewDay VARCHAR(16)
356 )
357 BEGIN
358 DROP TABLE IF EXISTS tempresv;
359 CREATE TEMPORARY TABLE tempresv AS SELECT * FROM FigReserve;
360 truncate TABLE tmpTable;
361
362 INSERT INTO tmpTable SELECT * FROM FigReserve
363 WHERE
364 FigReserve.FR_dtPubDate = strOldDay and
365 FigReserve.FR_nPubMask = nPubMask and
366 FigReserve.FR_nGridID = nGridID and
367 FigReserve.FR_nEditionMask = nEditionID;
368
369 UPDATE tempresv
370 SET FR_dtPubDate=strNewDay;
371 INSERT INTO FigReserve
372 SELECT * FROM tempresv;
373
374 END;
375
376
377 事务:
378 sqlserver:
379 CREATE PROCEDURE [dbo].[usp_getserialex] @serialname varchar(20), @nResult INT OUTPUT AS
380 begin
381 declare @serialno int
382 begin transaction
383 select @serialno = E5VALUE from E5ID with(TABLOCKX HOLDLOCK) where E5IDENTIFIER = @serialname
384 if @serialno is null
385 begin
386 commit
387 --raiserror 50010 'SystemVariable lack record'
388 end
389 else
390 begin
391 update E5ID set E5VALUE = @serialno+1 where E5IDENTIFIER = @serialname
392 commit
393 SELECT @nResult = @serialno+1
394 end
395 end;
396 end;
397
398 mysql:
399
400 DROP PROCEDURE if EXISTS usp_getserialex;
401 CREATE PROCEDURE usp_getserialex
402 (
403 serialname varchar(20), OUT nResult INT
404 )
405 begin
406 declare serialno int;
407 START transaction; -- TRANSACTION mysql用start(开始事务) where 前with(TABLOCKX HOLDLOCK)
408 select serialno = E5VALUE from E5ID where E5IDENTIFIER = serialname;
409 if serialno is null
410 then
411 commit;
412 -- raiserror 50010 'SystemVariable lack record'
413 else
414 update E5ID set E5VALUE = serialno+1 where E5IDENTIFIER = serialname;
415 commit;
416 SELECT nResult = serialno+1 ;
417 end if;
418 end;
419
420 function 的区别:
421 mysql function中不能用select
422
423 ifnull:的用法,代替sqlserver中的isnull
424 ifnull函数,如果字段不为null,则取第二个值,如果为空,取第三个值
425 select comm,ifnull(comm,comm+100,100) as comm2 from tb_emp;
426
427 ifnull函数,如果字段不为null,则直接返回该值,如果为空,取第二个
428 select comm,ifnull (comm,100)as comm2 from tb_demp;
429
430
431 sqlserver:
432 CREATE FUNCTION [dbo].[oms_getAdvMaterialOriginalPath]
433 (
434 @AdvID numeric(10,0)
435 )
436 RETURNS VARCHAR(4000)
437 AS
438 BEGIN
439 DECLARE @matUrl VARCHAR(4000)
440 IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AdvMaterial]') AND type in (N'U'))
441 begin
442 RETURN @matUrl
443 end
444
445 select @matUrl=isnull(@matUrl+',','')+AdvMaterial_Attachment.ATT_OriginalPath
446 from AdvItem,AdvMaterial,AdvMaterial_Attachment
447 where AdvItem.AI_ArticleID=AdvMaterial.SYS_DOCUMENTID
448 and AdvMaterial.SYS_DOCUMENTID=AdvMaterial_Attachment.ATT_MaterialID
449 and AdvItem.SYS_DOCUMENTID=@advID
450 and AdvMaterial.SYS_DELETEFLAG=0
451 and AdvMaterial_Attachment.SYS_DELETEFLAG=0
452
453 RETURN @matUrl
454 END;
455
456 mysql:
457 CREATE FUNCTION oms_getAdvMaterialOriginalPath
458 (
459 AdvID numeric(10,0)
460 )
461 RETURNS VARCHAR(4000)
462 BEGIN
463 DECLARE matUrl VARCHAR(4000);
464 -- if (select table_name from `INFORMATION_SCHEMA`.`TABLES` where table_name ='AdvMaterial' and TABLE_SCHEMA='omstest') = NULL
465 if EXISTS (select 1 from `INFORMATION_SCHEMA`.`TABLES` WHERE table_name ='AdvMaterial' and TABLE_SCHEMA=database()) //判断存在
466
467 THEN
468 select ifnull(matUrl+',','')+AdvMaterial_Attachment.ATT_OriginalPath into matUrl //isnull,ifnull
469 from AdvItem,AdvMaterial,AdvMaterial_Attachment
470 where AdvItem.AI_ArticleID=AdvMaterial.SYS_DOCUMENTID
471 and AdvMaterial.SYS_DOCUMENTID=AdvMaterial_Attachment.ATT_MaterialID
472 and AdvItem.SYS_DOCUMENTID=advID
473 and AdvMaterial.SYS_DELETEFLAG=0
474 and AdvMaterial_Attachment.SYS_DELETEFLAG=0;
475 end if;
476 RETURN matUrl;
477 END;
478 ----------------------------
479 select区别:
480
481 1,SELECT @A_Area=ISNULL(SUM(AI_AdvPages),0) FROM AdvItem WHERE SYS_DELETEFLAG=0 AND AI_IfCanceled=0 AND AI_PublishTime=@APubDate AND AI_Publication_ID=@APubID
482
483 2,SELECT IFNULL(SUM(AI_AdvPages),0) into A_Area
484 FROM AdvItem
485 WHERE SYS_DELETEFLAG=0 AND AI_IfCanceled=0 AND AI_PublishTime=APubDate AND AI_Publication_ID=APubID;
486
487 ------------------------------------------------------------------------------------------------------------------------------------------------
488 index区别(p5):
489 索引:
490 作用:在数据库中来加速对表的查询
491 创建:自动在主键和唯一键上面创建索引
492
493 手动创建:create index index_tb_student_name
494 on tb_student(stu_name)
495
496 使用索引,在where之后加上索引,提高查询效率
497
498
499 SHOW INDEX FROM AdvDoc; 显示这张表中的所有索引
500
501 CREATE INDEX IDX01_AdvDoc ON AdvDoc(F_OrderID); 添加这张表的索引
502
503 CREATE INDEX IDX01_AdvDoc ON AdvDoc(F_OrderID, F_Size_ID, F_Color_ID, F_Width, F_Height, F_Content);
504
505 SHOW INDEX FROM AdvDoc; 显示所有索引
506
507 DROP INDEX IDX01_AdvDoc ON AdvDoc; 删除索引,根据索引名称
508
509
510 ALTER TABLE [dbo].[AdvItem] DROP CONSTRAINT [PK_AdvItem];
511 变:
512 ALTER TABLE AdvItem DROP primary key;
513
514
515 ALTER TABLE [dbo].[AdvItem] ADD CONSTRAINT [PK_AdvItem] PRIMARY KEY NONCLUSTERED
516 (
517 [SYS_DOCUMENTID] ASC
518 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY];
519
520 Alter table AdvItem add primary key(SYS_DOCUMENTID);