Sybase 序列 [英] Sybase Sequence
问题描述
我正在 sybase 中创建一个序列,但被提及异常,有人可以帮忙吗?
I am creating a sequence in sybase but getting mentioned exception, can anyone please help?
CREATE OR REPLACE SEQUENCE dbo.event_id_sequence
START WITH 100
INCREMENT BY 1
MINVALUE 100
NO MAXVALUE
NO CACHE
NO CYCLE
go
GRANT USAGE ON SEQUENCE dbo.event_id_sequence TO userID maintenance
GRANT USAGE ON SEQUENCE dbo.event_id_sequence TO userID readonly
GRANT USAGE ON SEQUENCE dbo.event_id_sequence TO userID reports
go
异常:
[错误] 脚本行:1-14 -------------------------关键字REPLACE"附近的语法不正确.消息:156,级别:15,状态:2[执行:7/7/14 2:06:02 PM EDT] [执行:0/ms]
[Error] Script lines: 1-14 ------------------------- Incorrect syntax near the keyword 'REPLACE'. Msg: 156, Level: 15, State: 2 [Executed: 7/7/14 2:06:02 PM EDT ] [Execution: 0/ms]
[错误] 脚本行:15-19 ------------------------USAGE"附近的语法不正确.消息:102,级别:15,状态:84
[Error] Script lines: 15-19 ------------------------ Incorrect syntax near 'USAGE'. Msg: 102, Level: 15, State: 84
[错误] 脚本行:15-19 ------------------------USAGE"附近的语法不正确.消息:102,级别:15,状态:84
[Error] Script lines: 15-19 ------------------------ Incorrect syntax near 'USAGE'. Msg: 102, Level: 15, State: 84
[错误] 脚本行:15-19 ------------------------USAGE"附近的语法不正确.消息:102,级别:15,状态:84
[Error] Script lines: 15-19 ------------------------ Incorrect syntax near 'USAGE'. Msg: 102, Level: 15, State: 84
[执行:7/7/14 2:06:02 PM EDT] [执行:0/ms]
[Executed: 7/7/14 2:06:02 PM EDT ] [Execution: 0/ms]
推荐答案
Sybase ASE 没有 sequence
,您找到的代码可能是从 Sybase IQ 或可能的 SQL Anywhere 中提取的.
Sybase ASE does not have sequence
, the code you found is likely pulled from Sybase IQ or possible SQL Anywhere.
您应该考虑使用 IDENTITY
列.
Instead of using sequence
, you should look at using IDENTITY
columns instead.
如果这不适合您的需求,Sybase 建议许多其他方法可能会为您提供所需的内容.
If that does not suit your needs, Sybase suggests a number of other approaches that may give you what you are looking for.
方法:
可用于产生单调序列的方法有:
Methods which can be used to produce a monotonic series are:
最大加一
增强型 Max Plus One
Enhanced Max Plus One
下一个关键表
身份属性
所有这些都在链接文档中详细说明.
All of these are detailed in the linked document.
我还建议在 从 SAP Techwave 从 Oracle 迁移到 ASE.有一些关于如何使用序列表/过程模拟 SEQUENCE 的示例代码.
I would also suggest reviewing page 20 of this presentation on Migration from Oracle to ASE from SAP Techwave. There is some sample code on how to emulate SEQUENCE using a sequence table/procedure.
CREATE TABLE my_seq (seq int)
go
//initialize the sequence
INSERT INTO my_seq select 0
go
CREATE PROCEDURE get_seq (@seq int OUTPUT)
AS UPDATE my_seq SET seq = seq+1
SELECT @seq = seq FROM my_seq
go
// execute the sp to get the next sequence number
DECLARE @seq int
EXEC get_seq @seq OUTPUT
INSERT INTO m_table VALUES (@seq,..)
go
过期链接 - http://www.sybase.com/detail?id=860
这篇关于Sybase 序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!