Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit297c165

Browse files
committed
Information schema improvements
1 parent310049a commit297c165

File tree

2 files changed

+374
-128
lines changed

2 files changed

+374
-128
lines changed

‎doc/src/sgml/information_schema.sgml

Lines changed: 179 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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 $ -->
22

33
<chapter id="information-schema">
44
<title>The Information Schema</title>
@@ -148,7 +148,8 @@
148148
<para>
149149
The view <literal>check_constraints</literal> contains all check
150150
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.)
152153
</para>
153154

154155
<table>
@@ -266,7 +267,9 @@
266267
<para>
267268
The view <literal>columns</literal> contains information about all
268269
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).
270273
</para>
271274

272275
<table>
@@ -335,38 +338,47 @@
335338
<row>
336339
<entry><literal>data_type</literal></entry>
337340
<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>
339350
</row>
340351

341352
<row>
342353
<entry><literal>character_maximum_length</literal></entry>
343354
<entry><type>cardinal_number</type></entry>
344355
<entry>
345-
Ifthe column hasa 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> identifiesa character or bit
357+
string type, the declaredmaximum length; null for all other
358+
data types or if no maximumlength was declared.
348359
</entry>
349360
</row>
350361

351362
<row>
352363
<entry><literal>character_octet_length</literal></entry>
353364
<entry><type>cardinal_number</type></entry>
354365
<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.
358370
</entry>
359371
</row>
360372

361373
<row>
362374
<entry><literal>numeric_precision</literal></entry>
363375
<entry><type>cardinal_number</type></entry>
364376
<entry>
365-
Ifthe column hasa 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> identifiesa 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. Itmay be expressed in decimal (base 10)
381+
or binary (base 2) terms,as specified in the column
370382
<literal>numeric_precision_radix</literal>. For all other data
371383
types, this column is null.
372384
</entry>
@@ -376,8 +388,8 @@
376388
<entry><literal>numeric_precision_radix</literal></entry>
377389
<entry><type>cardinal_number</type></entry>
378390
<entry>
379-
Ifthe column hasa numeric type, this column indicates in
380-
which base the values in the columns
391+
If<literal>data_type</literal> identifiesa numeric type, this
392+
column indicates inwhich base the values in the columns
381393
<literal>numeric_precision</literal> and
382394
<literal>numeric_scale</literal> are expressed. The value is
383395
either 2 or 10. For all other data types, this column is null.
@@ -388,11 +400,12 @@
388400
<entry><literal>numeric_scale</literal></entry>
389401
<entry><type>cardinal_number</type></entry>
390402
<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
396409
<literal>numeric_precision_radix</literal>. For all other data
397410
types, this column is null.
398411
</entry>
@@ -402,9 +415,9 @@
402415
<entry><literal>datetime_precision</literal></entry>
403416
<entry><type>cardinal_number</type></entry>
404417
<entry>
405-
Ifthe column hasa 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> identifiesa date, time, or
419+
interval type, the declaredprecision; null for all other data
420+
types or if no precision wasdeclared.
408421
</entry>
409422
</row>
410423

@@ -485,25 +498,28 @@
485498
<entry><literal>udt_catalog</literal></entry>
486499
<entry><type>sql_identifier</type></entry>
487500
<entry>
488-
Name of the database that the column data typeis defined in
489-
(alwaysthecurrent database), nullifthe column has a domain
490-
type.
501+
Name of the database that the column data type(the underlying
502+
type ofthedomain,ifapplicable) is defined in (always the
503+
current database)
491504
</entry>
492505
</row>
493506

494507
<row>
495508
<entry><literal>udt_schema</literal></entry>
496509
<entry><type>sql_identifier</type></entry>
497510
<entry>
498-
Name of the schema that the column data typeis defined in,
499-
null if thecolumn has a domain type.
511+
Name of the schema that the column data type(the underlying
512+
type of thedomain, if applicable) is defined in
500513
</entry>
501514
</row>
502515

503516
<row>
504517
<entry><literal>udt_name</literal></entry>
505518
<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>
507523
</row>
508524

509525
<row>
@@ -533,7 +549,11 @@
533549
<row>
534550
<entry><literal>dtd_identifier</literal></entry>
535551
<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>
537557
</row>
538558

539559
<row>
@@ -544,14 +564,117 @@
544564
</tbody>
545565
</tgroup>
546566
</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>
547670
</sect1>
548671

549672
<sect1 id="infoschema-domain-constraints">
550673
<title><literal>domain_constraints</literal></title>
551674

552675
<para>
553676
The view <literal>domain_constraints</literal> contains all
554-
constraints belonging to domains.
677+
constraints belonging to domains owned by the current user.
555678
</para>
556679

557680
<table>
@@ -883,26 +1006,36 @@
8831006
<row>
8841007
<entry><literal>unique_constraint_catalog</literal></entry>
8851008
<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>
8871014
</row>
8881015

8891016
<row>
8901017
<entry><literal>unique_constraint_schema</literal></entry>
8911018
<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>
8931023
</row>
8941024

8951025
<row>
8961026
<entry><literal>unique_constraint_name</literal></entry>
8971027
<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>
8991032
</row>
9001033

9011034
<row>
9021035
<entry><literal>match_option</literal></entry>
9031036
<entry><literal>character_data</literal></entry>
9041037
<entry>
905-
Match option of thereferential constraint:
1038+
Match option of theforeign key constraint:
9061039
<literal>FULL</literal>, <literal>PARTIAL</literal>, or
9071040
<literal>NONE</literal>.
9081041
</entry>
@@ -912,7 +1045,7 @@
9121045
<entry><literal>update_rule</literal></entry>
9131046
<entry><literal>character_data</literal></entry>
9141047
<entry>
915-
Update rule of thereferential constraint:
1048+
Update rule of theforeign key constraint:
9161049
<literal>CASCADE</literal>, <literal>SET NULL</literal>,
9171050
<literal>SET DEFAULT</literal>, <literal>RESTRICT</literal>,or
9181051
<literal>NO ACTION</literal>.
@@ -923,7 +1056,7 @@
9231056
<entry><literal>delete_rule</literal></entry>
9241057
<entry><literal>character_data</literal></entry>
9251058
<entry>
926-
Delete rule of thereferential constraint:
1059+
Delete rule of theforeign key constraint:
9271060
<literal>CASCADE</literal>, <literal>SET NULL</literal>,
9281061
<literal>SET DEFAULT</literal>, <literal>RESTRICT</literal>,or
9291062
<literal>NO ACTION</literal>.
@@ -939,7 +1072,7 @@
9391072

9401073
<para>
9411074
The view <literal>schemata</literal> contains all schemas in the
942-
current database.
1075+
current database that are owned by the current user.
9431076
</para>
9441077

9451078
<table>
@@ -1420,7 +1553,7 @@
14201553

14211554
<para>
14221555
The view <literal>table_constraints</literal> contains all
1423-
constraints belonging to tables.
1556+
constraints belonging to tables owned by the current user.
14241557
</para>
14251558

14261559
<table>
@@ -1583,7 +1716,9 @@
15831716

15841717
<para>
15851718
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).
15871722
</para>
15881723

15891724
<table>
@@ -1667,7 +1802,8 @@
16671802

16681803
<para>
16691804
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).
16711807
</para>
16721808

16731809
<table>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp