|
1 |
| -<!-- $Header: /cvsroot/pgsql/doc/src/sgml/information_schema.sgml,v 1.1 2003/05/18 20:55:56 petere Exp $ --> |
| 1 | +<!-- $Header: /cvsroot/pgsql/doc/src/sgml/information_schema.sgml,v 1.2 2003/05/25 09:36:09 petere Exp $ --> |
2 | 2 |
|
3 | 3 | <chapter id="information-schema">
|
4 | 4 | <title>The Information Schema</title>
|
|
148 | 148 | <para>
|
149 | 149 | The view <literal>check_constraints</literal> contains all check
|
150 | 150 | constraints, either defined on a table or on a domain, that are
|
151 |
| - owned by the current user. |
| 151 | + owned by the current user. (The owner of the table or domain is |
| 152 | + the owner of the constraint.) |
152 | 153 | </para>
|
153 | 154 |
|
154 | 155 | <table>
|
|
266 | 267 | <para>
|
267 | 268 | The view <literal>columns</literal> contains information about all
|
268 | 269 | table columns (or view columns) in the database. System columns
|
269 |
| - (<literal>oid</>, etc.) are not included. |
| 270 | + (<literal>oid</>, etc.) are not included. Only those columns are |
| 271 | + shown that the current user has access to (by way of being the |
| 272 | + owner or having some privilege). |
270 | 273 | </para>
|
271 | 274 |
|
272 | 275 | <table>
|
|
335 | 338 | <row>
|
336 | 339 | <entry><literal>data_type</literal></entry>
|
337 | 340 | <entry><type>character_data</type></entry>
|
338 |
| - <entry>Data type of the column</entry> |
| 341 | + <entry> |
| 342 | + Data type of the column, if it is a built-in type, else |
| 343 | + <literal>USER-DEFINED</literal> (in that case, the type is |
| 344 | + identified in <literal>udt_name</literal> and associated |
| 345 | + columns). If the column is based on a domain, this column |
| 346 | + refers to the type underlying the domain (and the domain is |
| 347 | + identified in <literal>domain_name</literal> and associated |
| 348 | + columns). |
| 349 | + </entry> |
339 | 350 | </row>
|
340 | 351 |
|
341 | 352 | <row>
|
342 | 353 | <entry><literal>character_maximum_length</literal></entry>
|
343 | 354 | <entry><type>cardinal_number</type></entry>
|
344 | 355 | <entry>
|
345 |
| - If the column has a character or bit string type, the declared |
346 |
| - maximum length; null for all other data types or if no maximum |
347 |
| - length was declared. |
| 356 | + If <literal>data_type</literal> identifies a character or bit |
| 357 | + string type, the declared maximum length; null for all other |
| 358 | + data types or if no maximum length was declared. |
348 | 359 | </entry>
|
349 | 360 | </row>
|
350 | 361 |
|
351 | 362 | <row>
|
352 | 363 | <entry><literal>character_octet_length</literal></entry>
|
353 | 364 | <entry><type>cardinal_number</type></entry>
|
354 | 365 | <entry>
|
355 |
| - If the column has a character type, the maximum possible length |
356 |
| - in octets (bytes) of a datum (this should not be of concern to |
357 |
| - PostgreSQL users); null for all other data types. |
| 366 | + If <literal>data_type</literal> identifies a character type, |
| 367 | + the maximum possible length in octets (bytes) of a datum (this |
| 368 | + should not be of concern to PostgreSQL users); null for all |
| 369 | + other data types. |
358 | 370 | </entry>
|
359 | 371 | </row>
|
360 | 372 |
|
361 | 373 | <row>
|
362 | 374 | <entry><literal>numeric_precision</literal></entry>
|
363 | 375 | <entry><type>cardinal_number</type></entry>
|
364 | 376 | <entry>
|
365 |
| - If the column has a numeric type, this column contains the |
366 |
| - (declared or implicit) precision of the type for this column. |
367 |
| - The precision indicates the number of significant digits. It |
368 |
| - may be expressed in decimal (base 10) or binary (base 2) terms, |
369 |
| - as specified in the column |
| 377 | + If <literal>data_type</literal> identifies a numeric type, this |
| 378 | + column contains the (declared or implicit) precision of the |
| 379 | + type for this column. The precision indicates the number of |
| 380 | + significant digits. It may be expressed in decimal (base 10) |
| 381 | + or binary (base 2) terms, as specified in the column |
370 | 382 | <literal>numeric_precision_radix</literal>. For all other data
|
371 | 383 | types, this column is null.
|
372 | 384 | </entry>
|
|
376 | 388 | <entry><literal>numeric_precision_radix</literal></entry>
|
377 | 389 | <entry><type>cardinal_number</type></entry>
|
378 | 390 | <entry>
|
379 |
| - If the column has a numeric type, this column indicates in |
380 |
| - which base the values in the columns |
| 391 | + If <literal>data_type</literal> identifies a numeric type, this |
| 392 | + column indicates in which base the values in the columns |
381 | 393 | <literal>numeric_precision</literal> and
|
382 | 394 | <literal>numeric_scale</literal> are expressed. The value is
|
383 | 395 | either 2 or 10. For all other data types, this column is null.
|
|
388 | 400 | <entry><literal>numeric_scale</literal></entry>
|
389 | 401 | <entry><type>cardinal_number</type></entry>
|
390 | 402 | <entry>
|
391 |
| - If the column has an exact numeric type, this column contains |
392 |
| - the (declared or implicit) scale of the type for this column. |
393 |
| - The scale indicates the number of significant digits to the |
394 |
| - right of the decimal point. It may be expressed in decimal |
395 |
| - (base 10) or binary (base 2) terms, as specified in the column |
| 403 | + If <literal>data_type</literal> identifies an exact numeric |
| 404 | + type, this column contains the (declared or implicit) scale of |
| 405 | + the type for this column. The scale indicates the number of |
| 406 | + significant digits to the right of the decimal point. It may |
| 407 | + be expressed in decimal (base 10) or binary (base 2) terms, as |
| 408 | + specified in the column |
396 | 409 | <literal>numeric_precision_radix</literal>. For all other data
|
397 | 410 | types, this column is null.
|
398 | 411 | </entry>
|
|
402 | 415 | <entry><literal>datetime_precision</literal></entry>
|
403 | 416 | <entry><type>cardinal_number</type></entry>
|
404 | 417 | <entry>
|
405 |
| - If the column has a date, time, or interval type, the declared |
406 |
| - precision; null for all other data types or if no precision was |
407 |
| - declared. |
| 418 | + If <literal>data_type</literal> identifies a date, time, or |
| 419 | + interval type, the declared precision; null for all other data |
| 420 | + types or if no precision was declared. |
408 | 421 | </entry>
|
409 | 422 | </row>
|
410 | 423 |
|
|
485 | 498 | <entry><literal>udt_catalog</literal></entry>
|
486 | 499 | <entry><type>sql_identifier</type></entry>
|
487 | 500 | <entry>
|
488 |
| - Name of the database that the column data type is defined in |
489 |
| - (always the current database), null if the column has a domain |
490 |
| - type. |
| 501 | + Name of the database that the column data type (the underlying |
| 502 | + type of the domain, if applicable) is defined in (always the |
| 503 | + current database) |
491 | 504 | </entry>
|
492 | 505 | </row>
|
493 | 506 |
|
494 | 507 | <row>
|
495 | 508 | <entry><literal>udt_schema</literal></entry>
|
496 | 509 | <entry><type>sql_identifier</type></entry>
|
497 | 510 | <entry>
|
498 |
| - Name of the schema that the column data type is defined in, |
499 |
| - null if the column has a domain type. |
| 511 | + Name of the schema that the column data type (the underlying |
| 512 | + type of the domain, if applicable) is defined in |
500 | 513 | </entry>
|
501 | 514 | </row>
|
502 | 515 |
|
503 | 516 | <row>
|
504 | 517 | <entry><literal>udt_name</literal></entry>
|
505 | 518 | <entry><type>sql_identifier</type></entry>
|
506 |
| - <entry>Name of the column data type, null if the column has a domain type.</entry> |
| 519 | + <entry> |
| 520 | + Name of the column data type (the underlying type of the |
| 521 | + domain, if applicable) |
| 522 | + </entry> |
507 | 523 | </row>
|
508 | 524 |
|
509 | 525 | <row>
|
|
533 | 549 | <row>
|
534 | 550 | <entry><literal>dtd_identifier</literal></entry>
|
535 | 551 | <entry><type>sql_identifier</type></entry>
|
536 |
| - <entry>Applies to a feature not available in PostgreSQL</entry> |
| 552 | + <entry> |
| 553 | + A unique identifier of the data type of the column (The |
| 554 | + specific format of the identifier is not defined and not |
| 555 | + guaranteed to remain the same in future versions.) |
| 556 | + </entry> |
537 | 557 | </row>
|
538 | 558 |
|
539 | 559 | <row>
|
|
544 | 564 | </tbody>
|
545 | 565 | </tgroup>
|
546 | 566 | </table>
|
| 567 | + |
| 568 | + <para> |
| 569 | + Since data types can be defined in a variety of ways in SQL, and |
| 570 | + PostgreSQL contains additional ways to define data types, their |
| 571 | + representation in the information schema can be somewhat difficult. |
| 572 | + The column <literal>data_type</literal> is supposed to identify the |
| 573 | + underlying built-in type of the column. In PostgreSQL, this means |
| 574 | + that the type is defined in the system catalog schema |
| 575 | + <literal>pg_catalog</literal>. This column may be useful if the |
| 576 | + application can handle the well-known built-in types specially (for |
| 577 | + example, format the numeric types differently or use the data in |
| 578 | + the precision columns). The columns <literal>udt_name</literal>, |
| 579 | + <literal>udt_schema</literal>, and <literal>udt_catalog</literal> |
| 580 | + always identify the underlying data type of the column, even if the |
| 581 | + column is based on a domain. (Since PostgreSQL treats built-in |
| 582 | + types like user-defined types, built-in types appear here as well. |
| 583 | + This is an extension of the SQL standard.) These columns should be |
| 584 | + used if an application wants to process data differently according |
| 585 | + to the type, because in that case it wouldn't matter if the column |
| 586 | + is really based on a domain. If the column is based on a domain, |
| 587 | + the identity of the domain is stored in the columns |
| 588 | + <literal>domain_name</literal>, <literal>domain_schema</literal>, |
| 589 | + and <literal>domain_catalog</literal>. If you want to pair up |
| 590 | + columns with their associated data types and treat domains as |
| 591 | + separate types, you could write <literal>coalesce(domain_name, |
| 592 | + udt_name)</literal>, etc. Finally, if you want to check whether |
| 593 | + two columns have the same type, use |
| 594 | + <literal>dtd_identifier</literal>. |
| 595 | + </para> |
| 596 | + </sect1> |
| 597 | + |
| 598 | + <sect1 id="infoschema-constraint-table-usage"> |
| 599 | + <title><literal>constraint_table_usage</literal></title> |
| 600 | + |
| 601 | + <para> |
| 602 | + The view <literal>constraint_table_usage</literal> identifies all |
| 603 | + tables in the current database that are used by some constraint and |
| 604 | + are owned by the current user. (This is different from the view |
| 605 | + <literal>table_constraints</literal>, which identifies all table |
| 606 | + constraints along with the table they are defined on.) For a |
| 607 | + foreign key constraint, this view identifies the table that the |
| 608 | + foreign key references. Unique and primary key constraints simply |
| 609 | + identify the table they belong to. Check constraints and not-null |
| 610 | + constraints are not included in this view. |
| 611 | + </para> |
| 612 | + |
| 613 | + <table> |
| 614 | + <title><literal>constraint_table_usage</literal> Columns</title> |
| 615 | + |
| 616 | + <tgroup cols="3"> |
| 617 | + <thead> |
| 618 | + <row> |
| 619 | + <entry>Name</entry> |
| 620 | + <entry>Data Type</entry> |
| 621 | + <entry>Description</entry> |
| 622 | + </row> |
| 623 | + </thead> |
| 624 | + |
| 625 | + <tbody> |
| 626 | + <row> |
| 627 | + <entry><literal>table_catalog</literal></entry> |
| 628 | + <entry><type>sql_identifier</type></entry> |
| 629 | + <entry> |
| 630 | + Name of the database that contains the table that is used by |
| 631 | + some constraint (always the current database) |
| 632 | + </entry> |
| 633 | + </row> |
| 634 | + |
| 635 | + <row> |
| 636 | + <entry><literal>table_schema</literal</entry> |
| 637 | + <entry><type>sql_identifier</type></entry> |
| 638 | + <entry> |
| 639 | + Name of the schema that contains the table that is used by some |
| 640 | + constraint |
| 641 | + </entry> |
| 642 | + </row> |
| 643 | + |
| 644 | + <row> |
| 645 | + <entry><literal>table_name</literal</entry> |
| 646 | + <entry><type>sql_identifier</type></entry> |
| 647 | + <entry>Name of the table that is used by some constraint</entry> |
| 648 | + </row> |
| 649 | + |
| 650 | + <row> |
| 651 | + <entry><literal>constraint_catalog</literal></entry> |
| 652 | + <entry><type>sql_identifier</type></entry> |
| 653 | + <entry>Name of the database that contains the constraint (always the current database)</entry> |
| 654 | + </row> |
| 655 | + |
| 656 | + <row> |
| 657 | + <entry><literal>constraint_schema</literal</entry> |
| 658 | + <entry><type>sql_identifier</type></entry> |
| 659 | + <entry>Name of the schema that contains the constraint</entry> |
| 660 | + </row> |
| 661 | + |
| 662 | + <row> |
| 663 | + <entry><literal>constraint_name</literal</entry> |
| 664 | + <entry><type>sql_identifier</type></entry> |
| 665 | + <entry>Name of the constraint</entry> |
| 666 | + </row> |
| 667 | + </tbody> |
| 668 | + </tgroup> |
| 669 | + </table> |
547 | 670 | </sect1>
|
548 | 671 |
|
549 | 672 | <sect1 id="infoschema-domain-constraints">
|
550 | 673 | <title><literal>domain_constraints</literal></title>
|
551 | 674 |
|
552 | 675 | <para>
|
553 | 676 | The view <literal>domain_constraints</literal> contains all
|
554 |
| - constraints belonging to domains. |
| 677 | + constraints belonging to domains owned by the current user. |
555 | 678 | </para>
|
556 | 679 |
|
557 | 680 | <table>
|
|
883 | 1006 | <row>
|
884 | 1007 | <entry><literal>unique_constraint_catalog</literal></entry>
|
885 | 1008 | <entry><literal>sql_identifier</literal></entry>
|
886 |
| - <entry>Not yet implemented</entry> |
| 1009 | + <entry> |
| 1010 | + Name of the database that contains the unique or primary key |
| 1011 | + constraint that the foreign key constraint references (always |
| 1012 | + the current database) |
| 1013 | + </entry> |
887 | 1014 | </row>
|
888 | 1015 |
|
889 | 1016 | <row>
|
890 | 1017 | <entry><literal>unique_constraint_schema</literal></entry>
|
891 | 1018 | <entry><literal>sql_identifier</literal></entry>
|
892 |
| - <entry>Not yet implemented</entry> |
| 1019 | + <entry> |
| 1020 | + Name of the schema that contains the unique or primary key |
| 1021 | + constraint that the foreign key constraint references |
| 1022 | + </entry> |
893 | 1023 | </row>
|
894 | 1024 |
|
895 | 1025 | <row>
|
896 | 1026 | <entry><literal>unique_constraint_name</literal></entry>
|
897 | 1027 | <entry><literal>sql_identifier</literal></entry>
|
898 |
| - <entry>Not yet implemented</entry> |
| 1028 | + <entry> |
| 1029 | + Name of the unique or primary key constraint that the foreign |
| 1030 | + key constraint references |
| 1031 | + </entry> |
899 | 1032 | </row>
|
900 | 1033 |
|
901 | 1034 | <row>
|
902 | 1035 | <entry><literal>match_option</literal></entry>
|
903 | 1036 | <entry><literal>character_data</literal></entry>
|
904 | 1037 | <entry>
|
905 |
| - Match option of the referential constraint: |
| 1038 | + Match option of the foreign key constraint: |
906 | 1039 | <literal>FULL</literal>, <literal>PARTIAL</literal>, or
|
907 | 1040 | <literal>NONE</literal>.
|
908 | 1041 | </entry>
|
|
912 | 1045 | <entry><literal>update_rule</literal></entry>
|
913 | 1046 | <entry><literal>character_data</literal></entry>
|
914 | 1047 | <entry>
|
915 |
| - Update rule of the referential constraint: |
| 1048 | + Update rule of the foreign key constraint: |
916 | 1049 | <literal>CASCADE</literal>, <literal>SET NULL</literal>,
|
917 | 1050 | <literal>SET DEFAULT</literal>, <literal>RESTRICT</literal>,or
|
918 | 1051 | <literal>NO ACTION</literal>.
|
|
923 | 1056 | <entry><literal>delete_rule</literal></entry>
|
924 | 1057 | <entry><literal>character_data</literal></entry>
|
925 | 1058 | <entry>
|
926 |
| - Delete rule of the referential constraint: |
| 1059 | + Delete rule of the foreign key constraint: |
927 | 1060 | <literal>CASCADE</literal>, <literal>SET NULL</literal>,
|
928 | 1061 | <literal>SET DEFAULT</literal>, <literal>RESTRICT</literal>,or
|
929 | 1062 | <literal>NO ACTION</literal>.
|
|
939 | 1072 |
|
940 | 1073 | <para>
|
941 | 1074 | The view <literal>schemata</literal> contains all schemas in the
|
942 |
| - current database. |
| 1075 | + current database that are owned by the current user. |
943 | 1076 | </para>
|
944 | 1077 |
|
945 | 1078 | <table>
|
|
1420 | 1553 |
|
1421 | 1554 | <para>
|
1422 | 1555 | The view <literal>table_constraints</literal> contains all
|
1423 |
| - constraints belonging to tables. |
| 1556 | + constraints belonging to tables owned by the current user. |
1424 | 1557 | </para>
|
1425 | 1558 |
|
1426 | 1559 | <table>
|
|
1583 | 1716 |
|
1584 | 1717 | <para>
|
1585 | 1718 | The view <literal>tables</literal> contains all tables and views
|
1586 |
| - defined in the current database. |
| 1719 | + defined in the current database. Only those tables and views are |
| 1720 | + shown that the current user has access to (by way of being the |
| 1721 | + owner or having some privilege). |
1587 | 1722 | </para>
|
1588 | 1723 |
|
1589 | 1724 | <table>
|
|
1667 | 1802 |
|
1668 | 1803 | <para>
|
1669 | 1804 | The view <literal>views</literal> contains all views defined in the
|
1670 |
| - current database. |
| 1805 | + current database. Only those views are shown that the current user |
| 1806 | + has access to (by way of being the owner or having some privilege). |
1671 | 1807 | </para>
|
1672 | 1808 |
|
1673 | 1809 | <table>
|
|
0 commit comments