8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 18:03:03 +01:00

Documentation for the generator increment.

This commit is contained in:
robocop 2014-04-09 07:38:09 +00:00
parent de7ed79414
commit 5f5feb54e1

View File

@ -244,7 +244,7 @@ alter view v_users (id, name) as
Function:
Makes it possible to specify non-default (which is CURRENT_USER) grantor in GRANT and REVOKE
Makes it possible to specify non-default (which is CURRENT_USER) grantor in GRANT and REVOKE
commands.
Syntax:
@ -265,7 +265,7 @@ GRANT R1 TO PUBLIC GRANTED BY USER1
GRANT R1 TO USER1 WITH ADMIN OPTION
Misc:
GRANTED BY form of clause is recommended by SQL standard. AS is supported by some other
GRANTED BY form of clause is recommended by SQL standard. AS is supported by some other
servers (Informix), and is added for better compatibility.
@ -289,18 +289,18 @@ Example:
create database 'peoples.fdb'
default character set win1252;
alter character set win1252
set default collation win_ptbr;
create table peoples (
id integer,
name varchar(50) -- will use the database default character set and the win1252 default collation
);
insert into peoples values (1, 'adriano');
insert into peoples values (2, 'ADRIANO');
-- will retrieve both records because win_ptbr is case insensitive
select * from peoples where name like 'A%';
@ -335,7 +335,7 @@ create database 'test.fdb'
Function:
When user is removed from security database (or any other authentication source),
it's useful to revoke his access to any object in database.
it's useful to revoke his access to any object in database.
Syntax:
@ -392,3 +392,73 @@ ALTER { SEQUENCE | GENERATOR } <sequence name> RESTART [ WITH <value> ]
Syntax present in 2.5 for reference:
ALTER SEQUENCE <sequence name> RESTART WITH <value>
16) Increment for sequences.
(Claudio Valderrama)
For 3.0, the options specified in (15) include INCREMENT:
{ CREATE | RECREATE } { SEQUENCE | GENERATOR } <sequence name> [ START WITH <value> ] [ INCREMENT [BY] <increment> ]
CREATE OR ALTER { SEQUENCE | GENERATOR } <sequence name> { RESTART | START WITH <value> } [ INCREMENT [BY] <increment> ]
ALTER { SEQUENCE | GENERATOR } <sequence name> RESTART [ WITH <value> ] [ INCREMENT [BY] <increment> ]
This is the increment that's applied to the SQL standard way of working with generators:
NEXT VALUE FOR <sequence name>
is equivalent to
gen_id(<sequence name>, <increment>)
The default increment for user generators is one and for system generators, zero. This makes possible
to apply NEXT VALUE FOR <sys generator>
since system generators cannot be changed by user requests now. Example:
create sequence seq increment 10; -- starts at zero and changes by 10
select next value for seq from rdb$database; -- result is 10
select gen_id(seq, 1) from rdb$database; -- result is 11, gen_id() is not affected by the increment.
If the database is new and no trigger has been defined, doing
select next value for rdb$procedures from rdb$database;
many times will produce zero again and again, because it's a system generator.
The increment cannot be zero for user generators. Example:
SQL> create generator g00 increment 0;
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-CREATE SEQUENCE G00 failed
-INCREMENT 0 is an illegal option for sequence G00
The change in the value of INCREMENT is a feature that takes effect for each request that starts
after the change commits. Procedures that are invoked for the first time after the change in INCREMENT
will use the new value if they contain NEXT VALUE FOR statements. Procedures that are already
running are not affected because they're cached. Procedures relying on NEXT VALUE FOR do not need
to be recompiled to see the new increment, but if they are running already, they are loaded and
no effect is seen. Of course, gen_id(gen, expression) is not affected by the increment.
17) More security for system objects.
(Claudio Valderrama)
For 3.0, system domains cannot be altered:
SQL> alter domain rdb$linger type boolean;
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-ALTER DOMAIN RDB$LINGER failed
-System domain RDB$LINGER cannot be modified
The value of a system generator cannot be changed by user requests:
SQL> select gen_id(rdb$procedures, 1) from rdb$database;
GEN_ID
=====================
Statement failed, SQLSTATE = 42000
System generator RDB$PROCEDURES cannot be modified
SQL> set generator rdb$procedures to 0;
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-SET GENERATOR RDB$PROCEDURES failed
-System generator RDB$PROCEDURES cannot be modified
Also, the name RDB$GENERATORS does not refer anymore to an invisible system
generator. The name can be applied to an user generator.