/usr/share/pgmodeler/conf/snippets.conf is in pgmodeler-common 0.9.1~beta-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 | <?xml version="1.0" encoding="UTF-8" ?>
<!--
CAUTION: Do not modify this file directly on it's code unless you know what you are doing.
Unexpected results may occur if the code is changed deliberately.
-->
<snippets>
<snippet id="agg_create" label="Create aggregate" object="aggregate" parsable="true" placeholders="true">
<![CDATA[[CREATE AGGREGATE ] {name} $sp ({types}) $sp ( $br
[ SFUNC = ] {transition}, $br
[ STYPE = ] {state-type} $br
$ob [ , FINALFUNC = ] {final} $sp $cb $br
$ob [ , INITCOND = ] {initial-cond} $sp $cb $br
$ob [ , SORTOP = ] {sort-op} $sp $cb $br
) $br]]>
</snippet>
<snippet id="cast_create" label="Create cast" object="cast" parsable="true" placeholders="true">
<![CDATA[[ CREATE CAST (] {source-type} [ AS ] {destiny-type}) $br
$ob [ WITH FUNCTION ] {function} [ | WITHOUT FUNCTION | INOUT ] $cb $br
$ob [ AS ASSIGNMENT | AS IMPLICIT ] $cb $br]]>
</snippet>
<snippet id="coll_create" label="Create collation" object="collation" parsable="true" placeholders="true">
<![CDATA[[CREATE COLLATION ] {name} ( $br
$ob [ LOCALE = ] {locale} [, ] $cb $br
$ob [ LC_COLLATE = ] {lc-collate}[, ] $cb $br
$ob [ LC_CTYPE = ] {lc-ctype} $sp $cb
) $br]]>
</snippet>
<snippet id="coll_clone" label="Create collation from another" object="collation" parsable="true" placeholders="true">
<![CDATA[[CREATE COLLATION ] {name} [ FROM ] {another-collation} $br]]>
</snippet>
<snippet id="conv_create" label="Create conversion" object="conversion" parsable="true" placeholders="true">
<![CDATA[[CREATE ] $ob $sp DEFAULT $sp $cb [ CONVERSION ] {name}
[ FOR ] {src-encoding} [ TO ] {dst-encoding} [ FROM ] {function} $br]]>
</snippet>
<snippet id="db_create" label="Create database" object="database" parsable="true" placeholders="true">
<![CDATA[[CREATE DATABASE ] {name} [ WITH] $br
$ob [ OWNER = ] {owner} $sp $cb $br
$ob [ TEMPLATE = ] {template} $sp $cb $br
$ob [ ENCODING = ] {encoding} $sp $cb $br
$ob [ LC_COLLATE = ] {lc-collate} $sp $cb $br
$ob [ LC_CTYPE = ] {lc-ctype} $sp $cb $br
$ob [ TABLESPACE = ] {tablespace} $sp $cb $br
$ob [ CONNECTION LIMIT = ] {connlimit} $sp $cb $br]]>
</snippet>
<snippet id="db_alterconnlim" label="Alter database connection limit" object="database" parsable="true" placeholders="true">
<![CDATA[[ALTER DATABASE ] {name} [ WITH CONNECTION LIMIT ] {connlimit} $br]]>
</snippet>
<snippet id="dom_create" label="Create domain" object="domain" parsable="true" placeholders="true">
<![CDATA[[CREATE DOMAIN ] {name} [ AS ] {type} $br
$ob [ COLLATE ] {collation} $cb $br
$ob [ DEFAULT ] {default-value} $cb $br
$ob [ CONSTRAINT ] {constraint} $cb $br
$ob [ NOT NULL | NULL | CHECK ] ({expression}) $cb $br]]>
</snippet>
<snippet id="dom_setdefault" label="Set domain's default value" object="domain" parsable="true" placeholders="true">
<![CDATA[[ALTER DOMAIN ] {name} [ SET DEFAULT ] {expression} $br]]>
</snippet>
<snippet id="dom_dropdefault" label="Drop domain's default value" object="domain" parsable="true" placeholders="true">
<![CDATA[[ALTER DOMAIN ] {name} [ DROP DEFAULT] $br]]>
</snippet>
<snippet id="dom_setnotnull" label="Set domain's not null constraint" object="domain" parsable="true" placeholders="true">
<![CDATA[[ALTER DOMAIN ] {name} [ SET NOT NULL] $br]]>
</snippet>
<snippet id="dom_dropnotnull" label="Drop domain's not null constraint" object="domain" parsable="true" placeholders="true">
<![CDATA[[ALTER DOMAIN ] {name} [ DROP NOT NULL] $br]]>
</snippet>
<snippet id="dom_addcheck" label="Add domain's check constraint" object="domain" parsable="true" placeholders="true">
<![CDATA[[ALTER DOMAIN ] {name} [ ADD CONSTRAINT ] {constraint} $br
[CHECK (] {expression} [) ] $ob [ NOT VALID ] $cb $br]]>
</snippet>
<snippet id="dom_dropconstr" label="Drop domain's constraint" object="domain" parsable="true" placeholders="true">
<![CDATA[[ALTER DOMAIN ] {name} [ DROP CONSTRAINT IF EXISTS ] {constraint} $sp $ob [ RESTRICT | CASCADE ] $cb $br]]>
</snippet>
<snippet id="dom_renconstr" label="Rename domain's constraint" object="domain" parsable="true" placeholders="true">
<![CDATA[[ALTER DOMAIN ] {name} [ RENAME CONSTRAINT ] {constraint} [ TO ] {new-name} $br]]>
</snippet>
<snippet id="dom_validconstr" label="Validate domain's constraint" object="domain" parsable="true" placeholders="true">
<![CDATA[[ALTER DOMAIN ] {name} [ VALIDATE CONSTRAINT ] {constraint} $br]]>
</snippet>
<snippet id="evnt_create" label="Create event trigger" object="eventtrigger" parsable="true" placeholders="true">
<![CDATA[[CREATE EVENT TRIGGER ] {name} $br
[ ON ] {event} $br
$ob [ WHEN TAG IN (] {values}) $sp $cb $br
[ EXECUTE PROCEDURE ] {function} $br]]>
</snippet>
<snippet id="evnt_enable" label="Enable event trigger" object="eventtrigger" parsable="true" placeholders="true">
<![CDATA[[ALTER EVENT TRIGGER ] {name} [ ENABLE ] $ob [ REPLICA | ALWAYS ] $cb $br]]>
</snippet>
<snippet id="evnt_disable" label="Disable event trigger" object="eventtrigger" parsable="true" placeholders="true">
<![CDATA[[ALTER EVENT TRIGGER ] {name} [ DISABLE] $br]]>
</snippet>
<snippet id="ext_create" label="Create extension" object="extension" parsable="true" placeholders="true">
<![CDATA[[CREATE EXTENSION IF NOT EXISTS ] {name} [ WITH] $br
$ob [ SCHEMA ] {schema} $sp $cb $br
$ob [ VERSION ] '{cur-version}' $sp $cb $br
$ob [ FROM ] '{old-version}' $sp $cb $br]]>
</snippet>
<snippet id="ext_update" label="Update extension" object="extension" parsable="true" placeholders="true">
<![CDATA[[ALTER EXTENSION ] {name} [ UPDATE ] $ob [ TO ] $ob $sp '{new-version}' $sp $cb $br]]>
</snippet>
<snippet id="func_create" label="Create function" object="function" parsable="true" placeholders="true">
<![CDATA[[CREATE OR REPLACE FUNCTION ] {name} $sp ({arg-types}) $br
-- arg-types: $sp $ob [ IN | OUT | INOUT | VARIADIC ] $cb $sp {arg-name} $sp {arg-type} $sp $ob [ DEFAULT ] $sp {expression} $sp $cb $ob [ , ... ] $cb
$br $br
[-- Function returns a single result or results of the same type ] $br
RETURNS $ob [ SET OF ] $cb $sp {return-type} $br
[-- Function returns a table ] $br
[RETURNS TABLE (] {col-name} $sp {col-type} $ob [, ...] $cb ) $br
$br
[-- Definition for C based function ] $br
[AS ] '{library}' [, ] '{definition}' $br
[-- Definition for SQL or PL/PGSQL based function ] $br
[AS $$] $br
{definition} $br
[$$] $br $br
WINDOW $br
$ob [ NOT ] $cb LEAKPROOF $br
{function-type} [ -- IMMUTABLE | STABLE | VOLATILE ] $br
{behavior-type} [ -- CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT ] $br
{security-type} [ -- ] $ob EXTERNAL $cb $sp SECURITY $ob [ INVOKER | DEFINER ] $cb $br
[COST ] {execution-cost} $br
[ROWS ] {row-amount} $br
[LANGUAGE ] {language} $br]]>
</snippet>
<snippet id="func_c" label="Create a C based function" object="function" parsable="true" placeholders="true">
<![CDATA[[CREATE OR REPLACE FUNCTION ] {name} $sp ({arg-types}) $br
RETURNS $sp {return-type} $br
[AS ] '{library}' [, ] '{definition}' $br
%if ({window}=="true") %then WINDOW $br %end
%if ({leakproof}=="true") %then LEAKPROOF $br %end
{function-type} $br
{behavior-type} $br
{security-type} $br
[COST ] {execution-cost} $br
[ROWS ] {row-amount} $br
[LANGUAGE c] $br]]>
</snippet>
<snippet id="func_sql" label="Create a SQL based function" object="function" parsable="true" placeholders="true">
<![CDATA[[CREATE OR REPLACE FUNCTION ] {name} $sp ({arg-types}) $br
RETURNS $sp {return-type} $br
[AS $$] $br
{definition} $br
[$$] $br
%if ({window}=="true") %then WINDOW $br %end
%if {function-type} %then {function-type} $br %end
%if ({leakproof}=="true") %then LEAKPROOF $br %end
%if {behavior-type} %then {behavior-type} $br %end
%if {security-type} %then {security-type} $br %end
%if {execution-cost} %then [COST ] {execution-cost} $br %end
%if {row-amount} %then [ROWS ] {row-amount} $br %end
[LANGUAGE sql] $br]]>
</snippet>
<snippet id="func_plpgsql" label="Create a PL/PGSQL based function" object="function" parsable="true" placeholders="true">
<![CDATA[[CREATE OR REPLACE FUNCTION ] {name} $sp ({arg-types}) $br
RETURNS $sp {return-type} $br
[AS $$] $br
{definition} $br
[$$] $br
%if ({window}=="true") %then WINDOW $br %end
%if {function-type} %then {function-type} $br %end
%if ({leakproof}=="true") %then LEAKPROOF $br %end
%if {behavior-type} %then {behavior-type} $br %end
%if {security-type} %then {security-type} $br %end
%if {execution-cost} %then [COST ] {execution-cost} $br %end
%if {row-amount} %then [ROWS ] {row-amount} $br %end
[LANGUAGE plpgsql] $br]]>
</snippet>
<snippet id="func_alterbehav" label="Alter a function's behavior" object="function" parsable="true" placeholders="true">
<![CDATA[[ALTER FUNCTION ] {signature} $br
$ob [ CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT ] $cb $br]]>
</snippet>
<snippet id="func_altertype" label="Alter a function's type" object="function" parsable="true" placeholders="true">
<![CDATA[[ALTER FUNCTION ] {signature} $br
$ob [ IMMUTABLE | STABLE | VOLATILE ] $cb $br]]>
</snippet>
<snippet id="func_altersec" label="Alter a function's security type" object="function" parsable="true" placeholders="true">
<![CDATA[[ALTER FUNCTION ] {signature} $br
$ob [ EXTERNAL ] $cb [ SECURITY ] $ob [ INVOKER | DEFINER ] $cb $br]]>
</snippet>
<snippet id="func_leakproof" label="Alter a function's leakproof status" object="function" parsable="true" placeholders="true">
<![CDATA[[ALTER FUNCTION ] {signature} $ob [ NOT ] $cb $sp LEAKPROOF $br]]>
</snippet>
<snippet id="func_altercost" label="Alter a function's execution cost" object="function" parsable="true" placeholders="true">
<![CDATA[[ALTER FUNCTION ] {signature} [ COST ] {execution-cost} $br]]>
</snippet>
<snippet id="func_alterrows" label="Alter a function's returned rows amount" object="function" parsable="true" placeholders="true">
<![CDATA[[ALTER FUNCTION ] {signature} [ ROWS ] {row-amount} $br]]>
</snippet>
<snippet id="idx_create" label="Create index" object="index" parsable="true" placeholders="true">
<![CDATA[[CREATE ] $ob [ UNIQUE ] $cb [ INDEX ] $ob [ CONCURRENTLY ] $cb $sp {name} [ ON ] {table} $br
[USING ] {index-type} $br
( {columns} [) | (] {expressions}) $br $br
[-- All indexes accepts FILLFACTOR value from 10 to 100 (default is 90)] $br
$ob [ WITH ( FILLFACTOR = ] {factor} [ ) ] $cb $br
[-- GiST indexes accepts BUFFERING storage paramenter ] $br
$ob [ WITH ( BUFFERING = ON | OFF | AUTO ) ] $cb $br
[-- GIN indexes accepts FASTUPDATE storage paramenter ] $br
$ob [ WITH ( FASTUPDATE = ON | OFF ) ] $cb $br
$br
$ob [ TABLESPACE ] {tablespace} $sp $cb $br
$ob [ WHERE ] {predicate} $sp $cb $br ]]>
</snippet>
<snippet id="lang_create" label="Create language" object="language" parsable="true" placeholders="true">
<![CDATA[[CREATE ] $ob [ OR REPLACE ] $cb [ LANGUAGE ] {name} $br]]>
</snippet>
<snippet id="lang_createfunc" label="Create language with functions" object="language" parsable="true" placeholders="true">
<![CDATA[[CREATE ] $ob [ OR REPLACE ] $cb $sp $ob [ TRUSTED ] $cb [ LANGUAGE ] {name} $br
[HANDLER ] {handler} $br
$ob [ INLINE ] {inline} $sp $cb $br
$ob [ VALIDATOR ] {validator} $sp $cb $br]]>
</snippet>
<snippet id="select_first_500v" label="Select first 500 rows" object="view" parsable="true" placeholders="true">
<![CDATA[[SELECT * FROM ] {name} [ LIMIT 500;]]]>
</snippet>
<snippet id="view_create" label="Create view" object="view" parsable="true" placeholders="true">
<![CDATA[[CREATE ] $ob [ OR REPLACE ]$cb $sp $ob [ TEMPORARY ] $cb $sp $ob [ RECURSIVE ] $cb [ VIEW ] {name} $br
[AS ] {definition} $br]]>
</snippet>
<snippet id="view_materialized" label="Create materialized view" object="view" parsable="true" placeholders="true">
<![CDATA[[CREATE MATERIALIZED VIEW ] {name} $br
$ob [ TABLESPACE ] {tablespace} $sp $cb $br
[AS ] {definition} $br]]>
</snippet>
<snippet id="opr_create" label="Create operator" object="operator" parsable="true" placeholders="true">
<![CDATA[[CREATE OPERATOR ] {name} [ (] $br
[PROCEDURE = ] {function} $br
$ob [, LEFTARG = ] {left-type} $sp $cb $br
$ob [, RIGHTARG = ] {right-type} $sp $cb $br
$ob [, COMMUTATOR = ] {commutator-op} $sp $cb $br
$ob [, NEGATOR = ] {negator-op} $sp $cb $br
$ob [, RESTRICT = ] {restriction} $sp $cb $br
$ob [, JOIN = ] {join} $sp $cb $br
$ob [, HASHES ] $cb $br
$ob [, MERGES ] $cb $br
) $br]]>
</snippet>
<snippet id="opc_create" label="Create operator class" object="opclass" parsable="true" placeholders="true">
<![CDATA[[CREATE OPERATOR CLASS ] {name} $ob [ DEFAULT ] $cb [ FOR TYPE ] {type} $br
[USING ] {index-type} $sp $ob [ FAMILY ] {family} $sp $cb [ AS] $br
$br
[-- Create an OPERATOR element ] $br
[OPERATOR ] {stg-number} $sp {operator} $sp $ob [ FOR SEARCH | FOR ORDER BY ] $cb $sp {sort-family}
$br
[-- Create a FUNCTION element ] $br
[FUNCTION ] $sp {supp-number} $sp {function}
$br
[-- Create a STORAGE element ] $br
[STORAGE ] {type} $br]]>
</snippet>
<snippet id="opf_create" label="Create operator family" object="opfamily" parsable="true" placeholders="true">
<![CDATA[[CREATE OPERATOR FAMILY ] {name} [ USING ] {index-type} $br]]>
</snippet>
<snippet id="rol_create" label="Create role" object="role" parsable="true" placeholders="true">
<![CDATA[[CREATE ROLE ] {name} [ WITH ] $br
SUPERUSER $br
CREATEDB $br
CREATEROLE $br
INHERIT $br
LOGIN $br
REPLICATION $br
[CONNECTION LIMIT ] {connlimit} $br
$ob [ ENCRYPTED | UNENCRYPTED ] $cb [ PASSWORD ] '{password}' $br
[VALID UNTIL ] '{validity}' $br
[IN ROLE ] {ref-roles} $br
[ROLE ] {member-roles} $br
[ADMIN ] {admin-roles} $br]]>
</snippet>
<snippet id="rol_clone" label="Clone role" object="role" parsable="true" placeholders="false">
<![CDATA[[CREATE ROLE ] {name} [ WITH ] $br
%if ({superuser}=="true") %then SUPERUSER $br %end
%if ({createdb}=="true") %then CREATEDB $br %end
%if ({createrole}=="true") %then CREATEROLE $br %end
%if ({inherit}=="true") %then INHERIT $br %end
%if ({login}=="true") %then LOGIN $br %end
%if ({replication}=="true") %then REPLICATION $br %end
%if {connlimit} %then [CONNECTION LIMIT ] {connlimit} $br %end
%if ({encrypted}=="true") %then ENCRYPTED %else UNENCRYPTED %end
[ PASSWORD ] '{password}' $br
%if {validity} %then [VALID UNTIL ] '{validity}' $br %end
%if {ref-roles} %then [IN ROLE ] {ref-roles} $br %end
%if {member-roles} %then [ROLE ] {member-roles} $br %end
%if {admin-roles} %then [ADMIN ] {admin-roles} $br %end
$br]]>
</snippet>
<snippet id="rol_alter" label="Alter role attributes" object="role" parsable="true" placeholders="true">
<![CDATA[%set {no-mod} NO
[ALTER ROLE ] {name} [ WITH ] $br
%if ({superuser}=="false") %then {no-mod} %end SUPERUSER $br
%if ({createdb}=="false") %then {no-mod} %end CREATEDB $br
%if ({createrole}=="false") %then {no-mod} %end CREATEROLE $br
%if ({inherit}=="false") %then {no-mod} %end INHERIT $br
%if ({login}=="false") %then {no-mod} %end LOGIN $br
%if ({replication}=="false") %then {no-mod} %end REPLICATION $br
[CONNECTION LIMIT ] {connlimit} $br
$ob [ ENCRYPTED | UNENCRYPTED ] $cb [ PASSWORD ] '{new-password}' $br
[VALID UNTIL ] '{validity}' $br]]>
</snippet>
<snippet id="rule_create" label="Create rule" object="rule" parsable="true" placeholders="true">
<![CDATA[[CREATE ] $ob [ OR REPLACE ] $cb [ RULE ] {name} [ AS] $br
[ON ] {event-type} [ -- event-type: SELECT | INSERT | UPDATE | DELETE ] $br
[TO ] {table} $br
$ob [ WHERE ] {condition} $sp $cb $br
[DO ] {exec-type} [ -- exec-type: ALSO | INSTEAD ] $br
$br
[-- commands: NOTHING | command | (command; command; ...) ] $br
({commands}) $br]]>
</snippet>
<snippet id="sch_create" label="Create schema" object="schema" parsable="true" placeholders="true">
<![CDATA[[CREATE SCHEMA ] {name} $br]]>
</snippet>
<snippet id="seq_create" label="Create sequence" object="sequence" parsable="true" placeholders="true">
<![CDATA[[CREATE ] $ob [ TEMPORARY | TEMP ] $cb [ SEQUENCE ] {name} $br
$ob [ INCREMENT ] {increment} $sp $cb $br
$ob [ MINVALUE ] $ob $sp {min-value} [ | NO MINVALUE ] $cb $sp $cb $br
$ob [ MAXVALUE ] $ob $sp {max-value} [ | NO MAXVALUE ] $cb $sp $cb $br
$ob [ START ] {start} $sp $cb $br
$ob [ CACHE ] {cache} $sp $cb $br
$ob $sp $ob [ NO ] $cb [ CYCLE ] $sp $cb $br
$ob [ OWNED BY ] $ob $sp {owner-col} [ | NONE ] $cb $sp $cb $br]]>
</snippet>
<snippet id="seq_clone" label="Clone sequence" object="sequence" parsable="true" placeholders="false">
<![CDATA[[CREATE SEQUENCE ] {name} $br
[INCREMENT ] {increment} $br
[MINVALUE ] {min-value} $br
[MAXVALUE ] {max-value} $br
[START ] {start} $br
[CACHE ] {cache} $br
%if ({cycle}=="false") %then [NO ] %end CYCLE $br
[OWNED BY ] %if {owner-col} %then {owner-col} %else [ NONE] %end
$br]]>
</snippet>
<snippet id="seq_alter" label="Alter sequence" object="sequence" parsable="true" placeholders="true">
<![CDATA[[ALTER SEQUENCE ] {name} $br
[RESTART ] {restart} $br
[INCREMENT ] {increment} $br
[MINVALUE ] {min-value} $br
[MAXVALUE ] {max-value} $br
[START ] {start} $br
[CACHE ] {cache} $br
%if ({cycle}=="false") %then [NO ] %end CYCLE $br
[OWNED BY ] %if {owner-col} %then {owner-col} %else [ NONE] %end
$br]]>
</snippet>
<snippet id="tbs_create" label="Create tablespace" object="tablespace" parsable="true" placeholders="true">
<![CDATA[[CREATE TABLESPACE ] {name} $br
$ob [ OWNER ] {owner} $sp $cb $br
[LOCATION ] '{directory}' $br]]>
</snippet>
<snippet id="trg_create" label="Create trigger" object="trigger" parsable="true" placeholders="true">
<![CDATA[[CREATE ] $ob [ CONSTRAINT ] $cb [ TRIGGER ] {name} $br
{firing-type} [ -- BEFORE | AFTER | INSTEAD OF ] $br
{events} [ -- INSERT | DELETE | TRUNCATE | UPDATE ] $ob $sp [ OF {column} ] $ob [, ... ] $cb $sp $cb $br
[ON ] {table} $br
$br
[-- Constraint trigger attributes ] $br
$ob [ FROM ] {ref-table} $sp $cb $br
$ob [ NOT DEFERRABLE | DEFERRABLE ] $cb $sp $ob [ INITIALLY IMMEDIATE | INITIALLY DEFERRED ] $cb $br
$br
$ob [ FOR ] $ob [ EACH ] $cb $sp $ob [ ROW | STATEMENT ] $cb $sp $cb $br
$ob [ WHEN ] ({condition}) $sp $cb $br
[EXECUTE PROCEDURE ] {trigger-func} $br]]>
</snippet>
<snippet id="trg_clone" label="Clone trigger" object="trigger" parsable="true" placeholders="false">
<![CDATA[[CREATE ]
%if ({constraint}=="true") %then
[ CONSTRAINT ]
%end
[ TRIGGER ] {name} $br
{firing-type}
%if ({ins-event}=="true") %then
%set {event} [ INSERT ]
%end
%if ({del-event}=="true") %then
%if {event} %then
%set {event} {event} [ OR]
%end
%set {event} {event} [ DELETE ]
%end
%if ({trunc-event}=="true") %then
%if {event} %then
%set {event} {event} [ OR]
%end
%set {event} {event} [ TRUNCATE ]
%end
%if ({upd-event}=="true") %then
%if {event} %then
%set {event} {event} [ OR]
%end
%set {event} {event} [ UPDATE ]
%if {columns} %then
%set {event} {event} [OF ] {columns}
%end
%end
{event} $br
[ON ] {table} $br
%if ({constraint}=="true") %then
[FROM ] {ref-table} $br
%if ({deferrable}=="true") %then
[ DEFERRABLE ] {defer-type} $br
%else
[NOT DEFERRABLE ] $br
%end
%end
[FOR EACH ]
%if ({per-line}=="true") %then
ROW
%else
STATEMENT
%end
$br
%if {condition} %then
[WHEN ] ({condition}) $br
%end
[EXECUTE PROCEDURE ] {trigger-func} $br
]]>
</snippet>
<snippet id="type_comp" label="Create composite type" object="usertype" parsable="true" placeholders="true">
<![CDATA[[CREATE TYPE ] {name} [ AS (] $br
[ ] {attr-name} $sp {type} $sp $ob [ COLLATE ] {collation} $sp $cb $sp $ob [, ... ] $cb $sp $br
) $br]]>
</snippet>
<snippet id="type_enum" label="Create enumeration type" object="usertype" parsable="true" placeholders="true">
<![CDATA[[CREATE TYPE ] {name} [ AS ENUM ]
[( ] [ '{label}' ] $ob [, ... ] $cb $sp [ )] $br]]>
</snippet>
<snippet id="type_range" label="Create range type" object="usertype" parsable="true" placeholders="true">
<![CDATA[[CREATE TYPE ] {name} [ AS RANGE (] $br
[SUBTYPE = ] {subtype} $br
$ob [ , SUBTYPE_OPCLASS = ] {opclass} $sp $cb $br
$ob [ , COLLATION = ] {collation} $sp $cb $br
$ob [ , CANONICAL = ] {canonical} $sp $cb $br
$ob [ , SUBTYPE_DIFF = ] {subtypediff} $sp $cb $br
) $br]]>
</snippet>
<snippet id="type_base" label="Create base type" object="usertype" parsable="true" placeholders="true">
<![CDATA[[CREATE TYPE ] {name} [ (] $br
[INPUT = ] {input}, $br
[OUTPUT = ] {output} $br
$ob [ , RECEIVE = ] {receive} $sp $cb $br
$ob [ , SEND = ] {send} $sp $cb $br
$ob [ , TYPMOD_IN = ] {tpmodin} $sp $cb $br
$ob [ , TYPMOD_OUT = ] {tpmodout} $sp $cb $br
$ob [ , ANALYZE = ] {analyze} $sp $cb $br
$ob [ , INTERNALLENGTH = ] $ob {internal-length} | VARIABLE $sp $cb $br
$ob [ , PASSEDBYVALUE ] $cb $br
$ob [ , ALIGNMENT = ] {alignment} $sp $cb
[ -- integer | char | smallint | double precision ]$br
$ob [ , STORAGE = ] {storage} $sp $cb
[ -- plain | extended | external | main ]$br
$ob [ , LIKE = ] {like-type} $sp $cb
[ -- Type in which attributes will be copied ]$br
$ob [ , CATEGORY = ] '{category}' $sp $cb $br
$ob [ , PREFERRED = TRUE | FALSE ] $sp $cb $br
$ob [ , DEFAULT = ] {default-value} $sp $cb $br
$ob [ , ELEMENT = ] {element} $sp $cb
[ -- Type of elements when the type is array ]$br
$ob [ , DELIMITER = ] '{delimiter}' $sp $cb
[ -- Value delimiter when the type is array ]$br
$ob [ , COLLATABLE = TRUE | FALSE ] $cb $br
) $br]]>
</snippet>
<snippet id="type_renattr" label="Rename composite type attribute" object="usertype" parsable="true" placeholders="true">
<![CDATA[[ALTER TYPE ] {name} [ RENAME ATTRIBUTE ] {attribute} [ TO ] {new-name} $sp $ob [ CASCADE | RESTRICT ] $cb $br]]>
</snippet>
<snippet id="type_addattr" label="Add attribute to composite type" object="usertype" parsable="true" placeholders="true">
<![CDATA[[ALTER TYPE ] {name} [ ADD ATTRIBUTE ] {attr-name} $sp {type} $sp $ob [ COLLATE ] $sp {collation} $sp $cb $sp $ob [ CASCADE | RESTRICT ] $cb $br]]>
</snippet>
<snippet id="type_dropattr" label="Drop attribute from composite type" object="usertype" parsable="true" placeholders="true">
<![CDATA[[ALTER TYPE ] {name} [ DROP ATTRIBUTE IF EXISTS ] {attr-name} $sp $ob [ CASCADE | RESTRICT ] $cb $br]]>
</snippet>
<snippet id="type_alterattr" label="Change composite type attribute data type" object="usertype" parsable="true" placeholders="true">
<![CDATA[[ALTER TYPE ] {name} [ ALTER ATTRIBUTE ] {attr-name} [ TYPE ] {type} $sp $ob [ COLLATE ] $sp {collation} $sp $cb $sp $ob [ CASCADE | RESTRICT ] $cb $br]]>
</snippet>
<snippet id="type_addenum" label="Add element to enumeration type" object="usertype" parsable="true" placeholders="true">
<![CDATA[[ALTER TYPE ] {name} [ ADD VALUE IF NOT EXISTS ] {enum} $sp $ob [ BEFORE | AFTER ] {existing-enum} $sp $cb $br]]>
</snippet>
<snippet id="select_first_500" label="Select first 500 rows" object="table" parsable="true" placeholders="true">
<![CDATA[[SELECT * FROM ] {name} [ LIMIT 500;]]]>
</snippet>
<snippet id="tab_create" label="Create table" object="table" parsable="true" placeholders="true">
<![CDATA[[CREATE ] $ob [ TEMPORARY | UNLOGGED ] $cb [ TABLE IF NOT EXISTS ] {name} [ (] $br
[ ] {col-name} $sp {type} $sp $ob [ COLLATE ] {collation} $sp $cb , $br
[ ] {constraints} $br
[)] $br
$ob $sp $ob [ WITH | WITHOUT ] $cb [ OIDS ] $cb $br
$ob [ TABLESPACE ] {tablespace} $sp $cb $br]]>
</snippet>
<snippet id="tab_like" label="Create a dettached table (LIKE)" object="table" parsable="true" placeholders="true">
<![CDATA[[CREATE TABLE IF NOT EXISTS ] {new-name} [ (] $br
[ LIKE ] {name} $sp $ob $sp $ob [ INCLUDING | EXCLUDING ] $cb $sp $ob [ DEFAULTS | CONSTRAINTS | INDEXES | STORAGE | COMMENTS | ALL ] $cb $sp $cb $br
[)] $br
$ob [ TABLESPACE ] {tablespace} $sp $cb $br]]>
</snippet>
<snippet id="tab_inherit" label="Create inherited table" object="table" parsable="true" placeholders="true">
<![CDATA[[CREATE TABLE IF NOT EXISTS ] {new-name} [ (] $br
[)] $br
[INHERITS ] {name} [ -- name: comma separated list of tables ] $br
$ob [ TABLESPACE ] {tablespace} $sp $cb $br]]>
</snippet>
<snippet id="tab_idcolumn" label="Create a table with a single ID column of type 'serial'" object="table" parsable="true" placeholders="true">
<![CDATA[[CREATE TABLE IF NOT EXISTS ] {new-name} [ (] $br
[ id serial,] $br
[ CONSTRAINT ] {new-name}_pk [ PRIMARY KEY(id)] $br
[)] $br
$ob [ TABLESPACE ] {tablespace} $sp $cb $br]]>
</snippet>
<snippet id="col_create" label="Create column" object="column" parsable="true" placeholders="true">
<![CDATA[[ALTER TABLE IF EXISTS ] {table} $br
[ADD COLUMN ] {name} $sp {type} $sp $ob [ COLLATE ] {collation} $sp $cb $sp $ob
[ DEFAULT ] {default-value} $cb $sp $ob [ NOT NULL ] $cb $br]]>
</snippet>
<snippet id="col_settype" label="Change a column's data type" object="column" parsable="true" placeholders="true">
<![CDATA[[ALTER TABLE IF EXISTS ] {table} $br
[ALTER COLUMN ] {name} [ TYPE ] {type} $sp $ob [ COLLATE ] {collation} $sp $cb $br]]>
</snippet>
<snippet id="col_setdef" label="Set a column's default value" object="column" parsable="true" placeholders="true">
<![CDATA[[ALTER TABLE IF EXISTS ] {table} $br
[ALTER COLUMN ] {name} [ SET DEFAULT ] {default-value} $br]]>
</snippet>
<snippet id="col_dropdef" label="Drop a column's default value" object="column" parsable="true" placeholders="true">
<![CDATA[[ALTER TABLE IF EXISTS ] {table} $br
[ALTER COLUMN ] {name} [ DROP DEFAULT] $br]]>
</snippet>
<snippet id="col_setnotnull" label="Set a column's NOT NULL constraint" object="column" parsable="true" placeholders="true">
<![CDATA[[ALTER TABLE IF EXISTS ] {table} $br
[ALTER COLUMN ] {name} [ SET NOT NULL] $br]]>
</snippet>
<snippet id="col_dropnotnull" label="Drop a column's NOT NULL constraint" object="column" parsable="true" placeholders="true">
<![CDATA[[ALTER TABLE IF EXISTS ] {table} $br
[ALTER COLUMN ] {name} [ DROP NOT NULL] $br]]>
</snippet>
<snippet id="pk_create" label="Create PRIMARY KEY constraint" object="constraint" parsable="true" placeholders="true">
<![CDATA[[ALTER TABLE IF EXISTS ] {table} $br
[ADD CONSTRAINT ] {name} [ PRIMARY KEY (] {src-columns} ) $br]]>
</snippet>
<snippet id="uq_create" label="Create UNIQUE constraint" object="constraint" parsable="true" placeholders="true">
<![CDATA[[ALTER TABLE IF EXISTS ] {table} $br
[ADD CONSTRAINT ] {name} [ UNIQUE (] {src-columns} ) $br]]>
</snippet>
<snippet id="ck_create" label="Create CHECK constraint" object="constraint" parsable="true" placeholders="true">
<![CDATA[[ALTER TABLE IF EXISTS ] {table} $br
[ADD CONSTRAINT ] {name} [ CHECK (] {expression} ) $br]]>
</snippet>
<snippet id="fk_create" label="Create FOREIGN KEY constraint" object="constraint" parsable="true" placeholders="true">
<![CDATA[[ALTER TABLE IF EXISTS ] {table} $br
[ADD CONSTRAINT ] {name} [ FOREIGN KEY (] {src-columns} ) $br
[REFERENCES ] {ref-table} $sp ({ref-columns}) $br
$br
[-- Matching configuration ] $br
MATCH FULL | MATCH PARTIAL | MATCH SIMPLE $br
$br
[-- DELETE and UPDATE actions: NO ACTION | RESTRICT | CASCADE | SET NULL | SET DEFAULT ] $br
[ON DELETE ] {action} $br
[ON UPDATE ] {action} $br
$br
[-- Deferment configuration ] $br
[ DEFERRABLE | NOT DEFERRABLE ] $br
[ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] $br
$br]]>
</snippet>
<snippet id="fk_clone" label="Clones FOREIGN KEY constraint" object="constraint" parsable="true" placeholders="false">
<![CDATA[[ALTER TABLE IF EXISTS ] {table} $br
[ADD CONSTRAINT ] {name} [ FOREIGN KEY (] {src-columns} ) $br
[REFERENCES ] {ref-table} $sp ({dst-columns}) $br
{comparison-type} $br
[ON DELETE ] {del-action} $br
[ON UPDATE ] {upd-action} $br
%if {deferrable} %then
DEFERRABLE $sp {defer-type}
%else
[NOT DEFERRABLE]
%end
$br]]>
</snippet>
<snippet id="ex_create" label="Create EXCLUDE constraint" object="constraint" parsable="true" placeholders="true">
<![CDATA[[ALTER TABLE IF EXISTS ] {table} $br
[ADD CONSTRAINT ] {name} [ EXCLUDE ] $br
$ob [ USING ] {index-type} $cb $br
$br
[ -- Exclude element(s) configuration ] $br
$ob $sp {column} [ | ] ({expression}) $sp $cb $sp $ob $sp {opclass} $sp $cb
$sp $ob [ ASC | DESC ] $cb $sp $ob [ NULLS FIRST | NULLS LAST ] $cb $br
[ WITH ] {operator} $br
$br
$ob [ USING INDEX TABLESPACE ] {tablespace} $sp $cb $br
$ob [ WHERE (] {predicate} ) $cb $br]]>
</snippet>
<snippet id="obj_rename" label="Rename object" object="general" parsable="true" placeholders="false">
<![CDATA[%if ({object-type} != "column") %and ({object-type} != "constraint") %then
[ALTER ] {sql-object} $sp {signature}
[ RENAME TO ] $oc new-name $cc $br
%else
[ALTER TABLE ] {table} [ RENAME ] {sql-object} $sp {name}
[ TO ] $oc new-name $cc $br
%end]]>
</snippet>
<snippet id="set_owner" label="Set object's owner" object="general" parsable="true" placeholders="true">
<![CDATA[[ALTER ] {sql-object} $sp {signature} [ OWNER TO ] {owner} $br]]>
</snippet>
<snippet id="set_schema" label="Set object's schema" object="general" parsable="true" placeholders="true">
<![CDATA[[ALTER ] {sql-object} $sp {signature} [ SET SCHEMA ] {schema} $br]]>
</snippet>
<snippet id="set_schema" label="Set object's schema" object="general" parsable="true" placeholders="true">
<![CDATA[[ALTER ] {sql-object} $sp {signature} [ SET SCHEMA ] {schema} $br]]>
</snippet>
<snippet id="set_tablespace" label="Set object's tablespace" object="general" parsable="true" placeholders="true">
<![CDATA[[ALTER ] {sql-object} $sp {signature} [ SET TABLESPACE ] {tablespace} $br]]>
</snippet>
<snippet id="grant_privs" label="Grant privileges over an object" object="general" parsable="true" placeholders="false">
<![CDATA[[GRANT ] $ob $sp
%if %not {role} %and {owner} %then
%set {role} {owner}
%else
%set {role} $oc role $cc
%end
%if %not {signature} %then
%set {signature} $oc signature $cc
%end
# Unsetting some attributes that can affect the if's below
%unset {table} {view} {column} {sequence} {language}
%unset {usertype} {function} {aggregate} {database}
%unset {schema} {tablespace}
# Defining the an attribute related to object type to avoid bloat the
# code if comparison statements
%set {object-type} true
%if {table} %or {view} %or {column} %or {sequence} %then
[ SELECT | UPDATE |]
%end
%if {table} %or {view} %or {column} %then
[ INSERT | REFERENCES |]
%end
%if {table} %then
[ TRUNCATE |]
%end
%if {table} %or {view} %then
[ DELETE | TRIGGER |]
%end
%if {sequence} %or {language} %or {schema} %or {usertype} %or {domain} %then
[ USAGE |]
%end
%if {database} %or {schema} %or {tablespace} %then
[ CREATE |]
%end
%if {database} %then
[ CONNECT | TEMPORARY |]
%end
%if {function} %or {aggregate} %then
[ EXECUTE |]
%end
[ ALL PRIVILEGES ] $cb
$br
[ON ] {sql-object} $sp {signature} $br
[TO ] $ob $sp {role} [ | PUBLIC ] $cb $sp $ob [ WITH GRANT OPTION ] $cb
$br]]>
</snippet>
<snippet id="revoke_privs" label="Revoke privileges over an object" object="general" parsable="true" placeholders="false">
<![CDATA[[REVOKE ] $ob [ GRANT OPTION FOR ] $cb $ob $sp
%if %not {role} %and {owner} %then
%set {role} {owner}
%else
%set {role} $oc role $cc
%end
%if %not {signature} %then
%set {signature} $oc signature $cc
%end
# Unsetting some attributes that can affect the if's below
%unset {table} {view} {column} {sequence} {language}
%unset {usertype} {function} {aggregate} {database}
%unset {schema} {tablespace}
# Defining the an attribute related to object type to avoid bloat the
# code if comparison statements
%set {object-type} true
%if {table} %or {view} %or {column} %or {sequence} %then
[ SELECT | UPDATE |]
%end
%if {table} %or {view} %or {column} %then
[ INSERT | REFERENCES |]
%end
%if {table} %then
[ TRUNCATE |]
%end
%if {table} %or {view} %then
[ DELETE | TRIGGER |]
%end
%if {sequence} %or {language} %or {schema} %or {usertype} %or {domain} %then
[ USAGE |]
%end
%if {database} %or {schema} %or {tablespace} %then
[ CREATE |]
%end
%if {database} %then
[ CONNECT | TEMPORARY |]
%end
%if {function} %or {aggregate} %then
[ EXECUTE |]
%end
[ ALL PRIVILEGES ] $cb
$br
[ON ] {sql-object} $sp {signature} $br
[FROM ] $ob $sp {role} [ | PUBLIC ] $cb $sp $br
$ob [ CASCADE | RESTRICT ] $cb
$br]]>
</snippet>
</snippets>
|