Server IP : 85.214.239.14 / Your IP : 18.226.34.148 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/3/cwd/proc/3/root/usr/share/doc/postgresql-15/examples/ |
Upload File : |
DROP SEQUENCE next_id; DROP TABLE ids; CREATE SEQUENCE next_id START -2 MINVALUE -2; CREATE TABLE ids ( id int4, idesc text ); CREATE TRIGGER ids_nextid BEFORE INSERT OR UPDATE ON ids FOR EACH ROW EXECUTE PROCEDURE autoinc (id, next_id); INSERT INTO ids VALUES (0, 'first (-2 ?)'); INSERT INTO ids VALUES (null, 'second (-1 ?)'); INSERT INTO ids(idesc) VALUES ('third (1 ?!)'); SELECT * FROM ids; UPDATE ids SET id = null, idesc = 'first: -2 --> 2' WHERE idesc = 'first (-2 ?)'; UPDATE ids SET id = 0, idesc = 'second: -1 --> 3' WHERE id = -1; UPDATE ids SET id = 4, idesc = 'third: 1 --> 4' WHERE id = 1; SELECT * FROM ids; SELECT 'Wasn''t it 4 ?' as nextval, nextval ('next_id') as value; insert into ids (idesc) select textcat (idesc, '. Copy.') from ids; SELECT * FROM ids;