-
Notifications
You must be signed in to change notification settings - Fork 554
/
information-schema.rst
880 lines (763 loc) · 50.7 KB
/
information-schema.rst
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
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
.. highlight:: psql
.. _information_schema:
==================
Information schema
==================
``information_schema`` is a special schema that contains virtual tables which
are read-only and can be queried to get information about the state of the
cluster.
.. rubric:: Table of contents
.. contents::
:local:
Access
======
When the user management is enabled, accessing the ``information_schema`` is
open to all users and it does not require any privileges.
However, being able to query ``information_schema`` tables will not allow the
user to retrieve all the rows in the table, as it can contain information
related to tables over which the connected user does not have any privileges.
The only rows that will be returned will be the ones the user is allowed to
access.
For example, if the user ``john`` has any privilege on the ``doc.books`` table
but no privilege at all on ``doc.locations``, when ``john`` issues a ``SELECT *
FROM information_schema.tables`` statement, the tables information related to
the ``doc.locations`` table will not be returned.
Virtual tables
==============
.. _information_schema_tables:
``tables``
----------
The ``information_schema.tables`` virtual table can be queried to get a list of
all available tables and views and their settings, such as number of shards or
number of replicas.
.. hide: CREATE VIEW::
cr> CREATE VIEW galaxies AS
... SELECT id, name, description FROM locations WHERE kind = 'Galaxy';
CREATE OK, 1 row affected (... sec)
.. hide: CREATE TABLE::
cr> create table partitioned_table (
... id bigint,
... title text,
... date timestamp with time zone
... ) partitioned by (date);
CREATE OK, 1 row affected (... sec)
::
cr> SELECT table_schema, table_name, table_type, number_of_shards, number_of_replicas
... FROM information_schema.tables
... ORDER BY table_schema ASC, table_name ASC;
+--------------------+-------------------------+------------+------------------+--------------------+
| table_schema | table_name | table_type | number_of_shards | number_of_replicas |
+--------------------+-------------------------+------------+------------------+--------------------+
| doc | galaxies | VIEW | NULL | NULL |
| doc | locations | BASE TABLE | 2 | 0 |
| doc | partitioned_table | BASE TABLE | 4 | 0-1 |
| doc | quotes | BASE TABLE | 2 | 0 |
| information_schema | character_sets | BASE TABLE | NULL | NULL |
| information_schema | columns | BASE TABLE | NULL | NULL |
| information_schema | key_column_usage | BASE TABLE | NULL | NULL |
| information_schema | referential_constraints | BASE TABLE | NULL | NULL |
| information_schema | routines | BASE TABLE | NULL | NULL |
| information_schema | schemata | BASE TABLE | NULL | NULL |
| information_schema | sql_features | BASE TABLE | NULL | NULL |
| information_schema | table_constraints | BASE TABLE | NULL | NULL |
| information_schema | table_partitions | BASE TABLE | NULL | NULL |
| information_schema | tables | BASE TABLE | NULL | NULL |
| information_schema | views | BASE TABLE | NULL | NULL |
| pg_catalog | pg_am | BASE TABLE | NULL | NULL |
| pg_catalog | pg_attrdef | BASE TABLE | NULL | NULL |
| pg_catalog | pg_attribute | BASE TABLE | NULL | NULL |
| pg_catalog | pg_class | BASE TABLE | NULL | NULL |
| pg_catalog | pg_constraint | BASE TABLE | NULL | NULL |
| pg_catalog | pg_cursors | BASE TABLE | NULL | NULL |
| pg_catalog | pg_database | BASE TABLE | NULL | NULL |
| pg_catalog | pg_depend | BASE TABLE | NULL | NULL |
| pg_catalog | pg_description | BASE TABLE | NULL | NULL |
| pg_catalog | pg_enum | BASE TABLE | NULL | NULL |
| pg_catalog | pg_event_trigger | BASE TABLE | NULL | NULL |
| pg_catalog | pg_index | BASE TABLE | NULL | NULL |
| pg_catalog | pg_indexes | BASE TABLE | NULL | NULL |
| pg_catalog | pg_locks | BASE TABLE | NULL | NULL |
| pg_catalog | pg_namespace | BASE TABLE | NULL | NULL |
| pg_catalog | pg_proc | BASE TABLE | NULL | NULL |
| pg_catalog | pg_publication | BASE TABLE | NULL | NULL |
| pg_catalog | pg_publication_tables | BASE TABLE | NULL | NULL |
| pg_catalog | pg_range | BASE TABLE | NULL | NULL |
| pg_catalog | pg_roles | BASE TABLE | NULL | NULL |
| pg_catalog | pg_settings | BASE TABLE | NULL | NULL |
| pg_catalog | pg_shdescription | BASE TABLE | NULL | NULL |
| pg_catalog | pg_stats | BASE TABLE | NULL | NULL |
| pg_catalog | pg_subscription | BASE TABLE | NULL | NULL |
| pg_catalog | pg_subscription_rel | BASE TABLE | NULL | NULL |
| pg_catalog | pg_tables | BASE TABLE | NULL | NULL |
| pg_catalog | pg_tablespace | BASE TABLE | NULL | NULL |
| pg_catalog | pg_type | BASE TABLE | NULL | NULL |
| pg_catalog | pg_views | BASE TABLE | NULL | NULL |
| sys | allocations | BASE TABLE | NULL | NULL |
| sys | checks | BASE TABLE | NULL | NULL |
| sys | cluster | BASE TABLE | NULL | NULL |
| sys | health | BASE TABLE | NULL | NULL |
| sys | jobs | BASE TABLE | NULL | NULL |
| sys | jobs_log | BASE TABLE | NULL | NULL |
| sys | jobs_metrics | BASE TABLE | NULL | NULL |
| sys | node_checks | BASE TABLE | NULL | NULL |
| sys | nodes | BASE TABLE | NULL | NULL |
| sys | operations | BASE TABLE | NULL | NULL |
| sys | operations_log | BASE TABLE | NULL | NULL |
| sys | privileges | BASE TABLE | NULL | NULL |
| sys | repositories | BASE TABLE | NULL | NULL |
| sys | roles | BASE TABLE | NULL | NULL |
| sys | segments | BASE TABLE | NULL | NULL |
| sys | shards | BASE TABLE | NULL | NULL |
| sys | snapshot_restore | BASE TABLE | NULL | NULL |
| sys | snapshots | BASE TABLE | NULL | NULL |
| sys | summits | BASE TABLE | NULL | NULL |
| sys | users | BASE TABLE | NULL | NULL |
+--------------------+-------------------------+------------+------------------+--------------------+
SELECT 64 rows in set (... sec)
The table also contains additional information such as the specified
:ref:`routing column <gloss-routing-column>` and :ref:`partition columns
<gloss-partition-column>`::
cr> SELECT table_name, clustered_by, partitioned_by
... FROM information_schema.tables
... WHERE table_schema = 'doc'
... ORDER BY table_schema ASC, table_name ASC;
+-------------------+--------------+----------------+
| table_name | clustered_by | partitioned_by |
+-------------------+--------------+----------------+
| galaxies | NULL | NULL |
| locations | id | NULL |
| partitioned_table | _id | ["date"] |
| quotes | id | NULL |
+-------------------+--------------+----------------+
SELECT 4 rows in set (... sec)
.. rubric:: Schema
+----------------------------------+------------------------------------------------------------------------------------+-------------+
| Name | Description | Data Type |
+==================================+====================================================================================+=============+
| ``blobs_path`` | The data path of the blob table | ``TEXT`` |
+----------------------------------+------------------------------------------------------------------------------------+-------------+
| ``closed`` | The state of the table | ``BOOLEAN`` |
+----------------------------------+------------------------------------------------------------------------------------+-------------+
| ``clustered_by`` | The :ref:`routing column <gloss-routing-column>` used to cluster the table | ``TEXT`` |
+----------------------------------+------------------------------------------------------------------------------------+-------------+
| ``column_policy`` | Defines whether the table uses a ``STRICT`` or a ``DYNAMIC`` :ref:`column_policy` | ``TEXT`` |
+----------------------------------+------------------------------------------------------------------------------------+-------------+
| ``number_of_replicas`` | The number of replicas the table currently has | ``INTEGER`` |
+----------------------------------+------------------------------------------------------------------------------------+-------------+
| ``number_of_shards`` | The number of shards the table is currently distributed across | ``INTEGER`` |
+----------------------------------+------------------------------------------------------------------------------------+-------------+
| ``partitioned_by`` | The :ref:`partition columns <gloss-partition-column>` (used to partition the | ``TEXT`` |
| | table) | |
+----------------------------------+------------------------------------------------------------------------------------+-------------+
| ``reference_generation`` | Specifies how values in the self-referencing column are generated | ``TEXT`` |
+----------------------------------+------------------------------------------------------------------------------------+-------------+
| ``routing_hash_function`` | The name of the hash function used for internal :ref:`routing <sharding-routing>` | ``TEXT`` |
+----------------------------------+------------------------------------------------------------------------------------+-------------+
| ``self_referencing_column_name`` | The name of the column that uniquely identifies each row (always ``_id``) | ``TEXT`` |
+----------------------------------+------------------------------------------------------------------------------------+-------------+
| ``settings`` | :ref:`sql-create-table-with` | ``OBJECT`` |
+----------------------------------+------------------------------------------------------------------------------------+-------------+
| ``table_catalog`` | Refers to the ``table_schema`` | ``TEXT`` |
+----------------------------------+------------------------------------------------------------------------------------+-------------+
| ``table_name`` | The name of the table | ``TEXT`` |
+----------------------------------+------------------------------------------------------------------------------------+-------------+
| ``table_schema`` | The name of the schema the table belongs to | ``TEXT`` |
+----------------------------------+------------------------------------------------------------------------------------+-------------+
| ``table_type`` | The type of the table (``BASE TABLE`` for tables, ``VIEW`` for views) | ``TEXT`` |
+----------------------------------+------------------------------------------------------------------------------------+-------------+
| ``version`` | A collection of version numbers relevant to the table | ``OBJECT`` |
+----------------------------------+------------------------------------------------------------------------------------+-------------+
``settings``
............
Table settings specify configuration parameters for tables. Some settings can
be set during Cluster runtime and others are only applied on cluster restart.
This list of table settings in :ref:`sql-create-table-with` shows detailed
information of each parameter.
Table parameters can be applied with ``CREATE TABLE`` on creation of a table.
With ``ALTER TABLE`` they can be set on already existing tables.
The following statement creates a new table and sets the refresh interval of
shards to 500 ms and sets the :ref:`shard allocation <gloss-shard-allocation>`
for primary shards only::
cr> create table parameterized_table (id integer, content text)
... with ("refresh_interval"=500, "routing.allocation.enable"='primaries');
CREATE OK, 1 row affected (... sec)
The settings can be verified by querying ``information_schema.tables``::
cr> select settings['routing']['allocation']['enable'] as alloc_enable,
... settings['refresh_interval'] as refresh_interval
... from information_schema.tables
... where table_name='parameterized_table';
+--------------+------------------+
| alloc_enable | refresh_interval |
+--------------+------------------+
| primaries | 500 |
+--------------+------------------+
SELECT 1 row in set (... sec)
On existing tables this needs to be done with ``ALTER TABLE`` statement::
cr> alter table parameterized_table
... set ("routing.allocation.enable"='none');
ALTER OK, -1 rows affected (... sec)
.. hide:
cr> drop table parameterized_table;
DROP OK, 1 row affected (... sec)
``views``
---------
The table ``information_schema.views`` contains the name, definition and
options of all available views.
::
cr> SELECT table_schema, table_name, view_definition
... FROM information_schema.views
... ORDER BY table_schema ASC, table_name ASC;
+--------------+------------+-------------------------+
| table_schema | table_name | view_definition |
+--------------+------------+-------------------------+
| doc | galaxies | SELECT |
| | | "id" |
| | | , "name" |
| | | , "description" |
| | | FROM "locations" |
| | | WHERE "kind" = 'Galaxy' |
+--------------+------------+-------------------------+
SELECT 1 row in set (... sec)
.. rubric:: Schema
+---------------------+-------------------------------------------------------------------------------------+-------------+
| Name | Description | Data Type |
+=====================+=====================================================================================+=============+
| ``table_catalog`` | The catalog of the table of the view (refers to ``table_schema``) | ``TEXT`` |
+---------------------+-------------------------------------------------------------------------------------+-------------+
| ``table_schema`` | The schema of the table of the view | ``TEXT`` |
+---------------------+-------------------------------------------------------------------------------------+-------------+
| ``table_name`` | The name of the table of the view | ``TEXT`` |
+---------------------+-------------------------------------------------------------------------------------+-------------+
| ``view_definition`` | The SELECT statement that defines the view | ``TEXT`` |
+---------------------+-------------------------------------------------------------------------------------+-------------+
| ``check_option`` | Not applicable for CrateDB, always return ``NONE`` | ``TEXT`` |
+---------------------+-------------------------------------------------------------------------------------+-------------+
| ``is_updatable`` | Whether the view is updatable. Not applicable for CrateDB, always returns ``FALSE`` | ``BOOLEAN`` |
+---------------------+-------------------------------------------------------------------------------------+-------------+
| ``owner`` | The user that created the view | ``TEXT`` |
+---------------------+-------------------------------------------------------------------------------------+-------------+
.. note::
If you drop the table of a view, the view will still exist and show up in
the ``information_schema.tables`` and ``information_schema.views`` tables.
.. hide:
cr> DROP view galaxies;
DROP OK, 1 row affected (... sec)
.. _information_schema_columns:
``columns``
-----------
This table can be queried to get a list of all available columns of all tables
and views and their definition like data type and ordinal position inside the
table::
cr> select table_name, column_name, ordinal_position as pos, data_type
... from information_schema.columns
... where table_schema = 'doc' and table_name not like 'my_table%'
... order by table_name asc, column_name asc;
+-------------------+--------------------------------+-----+--------------------------+
| table_name | column_name | pos | data_type |
+-------------------+--------------------------------+-----+--------------------------+
| locations | date | 3 | timestamp with time zone |
| locations | description | 6 | text |
| locations | id | 1 | integer |
| locations | information | 11 | object_array |
| locations | information['evolution_level'] | 13 | smallint |
| locations | information['population'] | 12 | bigint |
| locations | inhabitants | 7 | object |
| locations | inhabitants['description'] | 9 | text |
| locations | inhabitants['interests'] | 8 | text_array |
| locations | inhabitants['name'] | 10 | text |
| locations | kind | 4 | text |
| locations | landmarks | 14 | text_array |
| locations | name | 2 | text |
| locations | position | 5 | integer |
| partitioned_table | date | 3 | timestamp with time zone |
| partitioned_table | id | 1 | bigint |
| partitioned_table | title | 2 | text |
| quotes | id | 1 | integer |
| quotes | quote | 2 | text |
+-------------------+--------------------------------+-----+--------------------------+
SELECT 19 rows in set (... sec)
You can even query this table's own columns (attention: this might lead to
infinite recursion of your mind, beware!)::
cr> select column_name, data_type, ordinal_position
... from information_schema.columns
... where table_schema = 'information_schema'
... and table_name = 'columns' order by column_name asc;
+--------------------------+------------+------------------+
| column_name | data_type | ordinal_position |
+--------------------------+------------+------------------+
| character_maximum_length | integer | 1 |
| character_octet_length | integer | 2 |
| character_set_catalog | text | 3 |
| character_set_name | text | 4 |
| character_set_schema | text | 5 |
| check_action | integer | 6 |
| check_references | text | 7 |
| collation_catalog | text | 8 |
| collation_name | text | 9 |
| collation_schema | text | 10 |
| column_default | text | 11 |
| column_details | object | 12 |
| column_details['name'] | text | 13 |
| column_details['path'] | text_array | 14 |
| column_name | text | 15 |
| data_type | text | 16 |
| datetime_precision | integer | 17 |
| domain_catalog | text | 18 |
| domain_name | text | 19 |
| domain_schema | text | 20 |
| generation_expression | text | 21 |
| identity_cycle | boolean | 22 |
| identity_generation | text | 23 |
| identity_increment | text | 24 |
| identity_maximum | text | 25 |
| identity_minimum | text | 26 |
| identity_start | text | 27 |
| interval_precision | integer | 28 |
| interval_type | text | 29 |
| is_generated | text | 30 |
| is_identity | boolean | 31 |
| is_nullable | boolean | 32 |
| numeric_precision | integer | 33 |
| numeric_precision_radix | integer | 34 |
| numeric_scale | integer | 35 |
| ordinal_position | integer | 36 |
| table_catalog | text | 37 |
| table_name | text | 38 |
| table_schema | text | 39 |
| udt_catalog | text | 40 |
| udt_name | text | 41 |
| udt_schema | text | 42 |
+--------------------------+------------+------------------+
SELECT 42 rows in set (... sec)
.. rubric:: Schema
+-------------------------------+-----------------------------------------------+---------------+
| Name | Description | Data Type |
+===============================+===============================================+===============+
| ``table_catalog`` | Refers to the ``table_schema`` | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``table_schema`` | Schema name containing the table | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``table_name`` | Table Name | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``column_name`` | Column Name | ``TEXT`` |
| | For fields in object columns this is not an | |
| | identifier but a path and therefore must not | |
| | be double quoted when programmatically | |
| | obtained. | |
+-------------------------------+-----------------------------------------------+---------------+
| ``ordinal_position`` | The position of the column within the | ``INTEGER`` |
| | table | |
+-------------------------------+-----------------------------------------------+---------------+
| ``is_nullable`` | Whether the column is nullable | ``BOOLEAN`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``data_type`` | The data type of the column | ``TEXT`` |
| | | |
| | For further information see :ref:`data-types` | |
+-------------------------------+-----------------------------------------------+---------------+
| ``column_default`` | The default :ref:`expression | ``TEXT`` |
| | <gloss-expression>` of the column | |
+-------------------------------+-----------------------------------------------+---------------+
| ``character_maximum_length`` | If the data type is a :ref:`character type | ``INTEGER`` |
| | <data-types-character-data>` then return the | |
| | declared length limit; otherwise ``NULL``. | |
+-------------------------------+-----------------------------------------------+---------------+
| ``character_octet_length`` | Not implemented (always returns ``NULL``) | ``INTEGER`` |
| | | |
| | Please refer to :ref:`type-text` type | |
+-------------------------------+-----------------------------------------------+---------------+
| ``numeric_precision`` | Indicates the number of significant digits | ``INTEGER`` |
| | for a numeric ``data_type``. For all other | |
| | data types this column is ``NULL``. | |
+-------------------------------+-----------------------------------------------+---------------+
| ``numeric_precision_radix`` | Indicates in which base the value in the | ``INTEGER`` |
| | column ``numeric_precision`` for a numeric | |
| | ``data_type`` is exposed. This can either be | |
| | 2 (binary) or 10 (decimal). For all other | |
| | data types this column is ``NULL``. | |
+-------------------------------+-----------------------------------------------+---------------+
| ``numeric_scale`` | Not implemented (always returns ``NULL``) | ``INTEGER`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``datetime_precision`` | Contains the fractional seconds precision for | ``INTEGER`` |
| | a ``timestamp`` ``data_type``. For all other | |
| | data types this column is ``null``. | |
+-------------------------------+-----------------------------------------------+---------------+
| ``interval_type`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``interval_precision`` | Not implemented (always returns ``NULL``) | ``INTEGER`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``character_set_catalog`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``character_set_schema`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``character_set_name`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``collation_catalog`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``collation_schema`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``collation_name`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``domain_catalog`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``domain_schema`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``domain_name`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``udt_catalog`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``udt_schema`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``udt_name`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``check_references`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``check_action`` | Not implemented (always returns ``NULL``) | ``INTEGER`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``generation_expression`` | The expression used to generate ad column. | ``TEXT`` |
| | If the column is not generated ``NULL`` is | |
| | returned. | |
+-------------------------------+-----------------------------------------------+---------------+
| ``is_generated`` | Returns ``ALWAYS`` or ``NEVER`` wether the | ``TEXT`` |
| | column is generated or not. | |
+-------------------------------+-----------------------------------------------+---------------+
| ``is_identity`` | Not implemented (always returns ``false``) | ``BOOLEAN`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``identity_cycle`` | Not implemented (always returns ``NULL``) | ``BOOLEAN`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``identity_generation`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``identity_increment`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``identity_maximum`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``identity_minimum`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
| ``identity_start`` | Not implemented (always returns ``NULL``) | ``TEXT`` |
+-------------------------------+-----------------------------------------------+---------------+
.. _information_schema_table_constraints:
``table_constraints``
---------------------
This table can be queried to get a list of all defined table constraints, their
type, name and which table they are defined in.
.. NOTE::
Currently only ``PRIMARY_KEY`` constraints are supported.
.. hide:
cr> create table tbl (col TEXT NOT NULL);
CREATE OK, 1 row affected (... sec)
::
cr> select table_schema, table_name, constraint_name, constraint_type as type
... from information_schema.table_constraints
... where table_name = 'tables'
... or table_name = 'quotes'
... or table_name = 'documents'
... or table_name = 'tbl'
... order by table_schema desc, table_name asc limit 10;
+--------------------+------------+------------------------+-------------+
| table_schema | table_name | constraint_name | type |
+--------------------+------------+------------------------+-------------+
| information_schema | tables | tables_pk | PRIMARY KEY |
| doc | quotes | quotes_pk | PRIMARY KEY |
| doc | quotes | doc_quotes_id_not_null | CHECK |
| doc | tbl | doc_tbl_col_not_null | CHECK |
+--------------------+------------+------------------------+-------------+
SELECT 4 rows in set (... sec)
``key_column_usage``
--------------------
This table may be queried to retrieve primary key information from all user
tables:
.. hide:
cr> create table students (id bigint, department integer, name text, primary key(id, department))
CREATE OK, 1 row affected (... sec)
::
cr> select constraint_name, table_name, column_name, ordinal_position
... from information_schema.key_column_usage
... where table_name = 'students'
+-----------------+------------+-------------+------------------+
| constraint_name | table_name | column_name | ordinal_position |
+-----------------+------------+-------------+------------------+
| students_pk | students | id | 1 |
| students_pk | students | department | 2 |
+-----------------+------------+-------------+------------------+
SELECT 2 rows in set (... sec)
.. rubric:: Schema
+-------------------------+-------------------------------------------------------------------------+-------------+
| Name | Description | Data Type |
+=========================+=========================================================================+=============+
| ``constraint_catalog`` | Refers to ``table_catalog`` | ``TEXT`` |
+-------------------------+-------------------------------------------------------------------------+-------------+
| ``constraint_schema`` | Refers to ``table_schema`` | ``TEXT`` |
+-------------------------+-------------------------------------------------------------------------+-------------+
| ``constraint_name`` | Name of the constraint | ``TEXT`` |
+-------------------------+-------------------------------------------------------------------------+-------------+
| ``table_catalog`` | Refers to ``table_schema`` | ``TEXT`` |
+-------------------------+-------------------------------------------------------------------------+-------------+
| ``table_schema`` | Name of the schema that contains the table that contains the constraint | ``TEXT`` |
+-------------------------+-------------------------------------------------------------------------+-------------+
| ``table_name`` | Name of the table that contains the constraint | ``TEXT`` |
+-------------------------+-------------------------------------------------------------------------+-------------+
| ``column_name`` | Name of the column that contains the constraint | ``TEXT`` |
+-------------------------+-------------------------------------------------------------------------+-------------+
| ``ordinal_position`` | Position of the column within the constraint (starts with 1) | ``INTEGER`` |
+-------------------------+-------------------------------------------------------------------------+-------------+
.. _is_table_partitions:
``table_partitions``
--------------------
This table can be queried to get information about all :ref:`partitioned tables
<partitioned-tables>`, Each partition of a table is represented as one row. The
row contains the information table name, schema name, partition ident, and the
values of the partition. ``values`` is a key-value object with the
:ref:`partition column <gloss-partition-column>` (or columns) as key(s) and the
corresponding value as value(s).
.. hide:
cr> create table a_partitioned_table (id integer, content text)
... partitioned by (content);
CREATE OK, 1 row affected (... sec)
::
cr> insert into a_partitioned_table (id, content) values (1, 'content_a');
INSERT OK, 1 row affected (... sec)
::
cr> alter table a_partitioned_table set (number_of_shards=5);
ALTER OK, -1 rows affected (... sec)
::
cr> insert into a_partitioned_table (id, content) values (2, 'content_b');
INSERT OK, 1 row affected (... sec)
The following example shows a table where the column ``content`` of table
``a_partitioned_table`` has been used to partition the table. The table has two
partitions. The partitions are introduced when data is inserted where
``content`` is ``content_a``, and ``content_b``.::
cr> select table_name, table_schema as schema, partition_ident, "values"
... from information_schema.table_partitions
... order by table_name, partition_ident;
+---------------------+--------+--------------------+--------------------------+
| table_name | schema | partition_ident | values |
+---------------------+--------+--------------------+--------------------------+
| a_partitioned_table | doc | 04566rreehimst2vc4 | {"content": "content_a"} |
| a_partitioned_table | doc | 04566rreehimst2vc8 | {"content": "content_b"} |
+---------------------+--------+--------------------+--------------------------+
SELECT 2 rows in set (... sec)
The second partition has been created after the number of shards for future
partitions have been changed on the partitioned table, so they show ``5``
instead of ``4``::
cr> select table_name, partition_ident,
... number_of_shards, number_of_replicas
... from information_schema.table_partitions
... order by table_name, partition_ident;
+---------------------+--------------------+------------------+--------------------+
| table_name | partition_ident | number_of_shards | number_of_replicas |
+---------------------+--------------------+------------------+--------------------+
| a_partitioned_table | 04566rreehimst2vc4 | 4 | 0-1 |
| a_partitioned_table | 04566rreehimst2vc8 | 5 | 0-1 |
+---------------------+--------------------+------------------+--------------------+
SELECT 2 rows in set (... sec)
``routines``
------------
The routines table contains tokenizers, token-filters, char-filters, custom
analyzers created by ``CREATE ANALYZER`` statements (see
:ref:`sql-ddl-custom-analyzer`), and :ref:`functions <user-defined-functions>`
created by ``CREATE FUNCTION`` statements::
cr> select routine_name, routine_type
... from information_schema.routines
... group by routine_name, routine_type
... order by routine_name asc limit 5;
+----------------------+--------------+
| routine_name | routine_type |
+----------------------+--------------+
| PathHierarchy | TOKENIZER |
| apostrophe | TOKEN_FILTER |
| arabic | ANALYZER |
| arabic_normalization | TOKEN_FILTER |
| arabic_stem | TOKEN_FILTER |
+----------------------+--------------+
SELECT 5 rows in set (... sec)
For example you can use this table to list existing tokenizers like this::
cr> select routine_name
... from information_schema.routines
... where routine_type='TOKENIZER'
... order by routine_name asc limit 10;
+----------------+
| routine_name |
+----------------+
| PathHierarchy |
| char_group |
| classic |
| edge_ngram |
| keyword |
| letter |
| lowercase |
| ngram |
| path_hierarchy |
| pattern |
+----------------+
SELECT 10 rows in set (... sec)
Or get an overview of how many routines and routine types are available::
cr> select count(*), routine_type
... from information_schema.routines
... group by routine_type
... order by routine_type;
+----------+--------------+
| count(*) | routine_type |
+----------+--------------+
| 45 | ANALYZER |
| 3 | CHAR_FILTER |
| 16 | TOKENIZER |
| 61 | TOKEN_FILTER |
+----------+--------------+
SELECT 4 rows in set (... sec)
.. rubric:: Schema
+--------------------+-------------+
| Name | Data Type |
+====================+=============+
| routine_name | ``TEXT`` |
+--------------------+-------------+
| routine_type | ``TEXT`` |
+--------------------+-------------+
| routine_body | ``TEXT`` |
+--------------------+-------------+
| routine_schema | ``TEXT`` |
+--------------------+-------------+
| data_type | ``TEXT`` |
+--------------------+-------------+
| is_deterministic | ``BOOLEAN`` |
+--------------------+-------------+
| routine_definition | ``TEXT`` |
+--------------------+-------------+
| specific_name | ``TEXT`` |
+--------------------+-------------+
:routine_name:
Name of the routine (might be duplicated in case of overloading)
:routine_type:
Type of the routine.
Can be ``FUNCTION``, ``ANALYZER``, ``CHAR_FILTER``, ``TOKEN_FILTER``
or ``TOKEN_FILTER``.
:routine_schema:
The schema where the routine was defined.
If it doesn't apply, then ``NULL``.
:routine_body:
The language used for the routine implementation.
If it doesn't apply, then ``NULL``.
:data_type:
The return type of the function.
If it doesn't apply, then ``NULL``.
:is_deterministic:
If the routine is deterministic then ``True``, else ``False`` (``NULL`` if
it doesn't apply).
:routine_definition:
The function definition (``NULL`` if it doesn't apply).
:specific_name:
Used to uniquely identify the function in a schema, even if the function is
overloaded. Currently the specific name contains the types of the function
arguments. As the format might change in the future, it should be only used
to compare it to other instances of ``specific_name``.
``schemata``
------------
The schemata table lists all existing schemas. The ``blob``,
``information_schema``, and ``sys`` schemas are always available. The ``doc``
schema is available after the first user table is created.
::
cr> select schema_name from information_schema.schemata order by schema_name;
+--------------------+
| schema_name |
+--------------------+
| blob |
| doc |
| information_schema |
| pg_catalog |
| sys |
+--------------------+
SELECT 5 rows in set (... sec)
.. _sql_features:
``sql_features``
----------------
The ``sql_features`` table outlines supported and unsupported SQL features of
CrateDB based to the current SQL standard (see :ref:`sql_supported_features`)::
cr> select feature_name, is_supported, sub_feature_id, sub_feature_name
... from information_schema.sql_features
... where feature_id='F501';
+--------------------------------+--------------+----------------+--------------------+
| feature_name | is_supported | sub_feature_id | sub_feature_name |
+--------------------------------+--------------+----------------+--------------------+
| Features and conformance views | FALSE | | |
| Features and conformance views | TRUE | 1 | SQL_FEATURES view |
| Features and conformance views | FALSE | 2 | SQL_SIZING view |
| Features and conformance views | FALSE | 3 | SQL_LANGUAGES view |
+--------------------------------+--------------+----------------+--------------------+
SELECT 4 rows in set (... sec)
+------------------+-----------+----------+
| Name | Data Type | Nullable |
+==================+===========+==========+
| feature_id | ``TEXT`` | NO |
+------------------+-----------+----------+
| feature_name | ``TEXT`` | NO |
+------------------+-----------+----------+
| sub_feature_id | ``TEXT`` | NO |
+------------------+-----------+----------+
| sub_feature_name | ``TEXT`` | NO |
+------------------+-----------+----------+
| is_supported | ``TEXT`` | NO |
+------------------+-----------+----------+
| is_verified_by | ``TEXT`` | YES |
+------------------+-----------+----------+
| comments | ``TEXT`` | YES |
+------------------+-----------+----------+
:feature_id:
Identifier of the feature
:feature_name:
Descriptive name of the feature by the Standard
:sub_feature_id:
Identifier of the sub feature;
If it has zero-length, this is a feature
:sub_feature_name:
Descriptive name of the sub feature by the Standard;
If it has zero-length, this is a feature
:is_supported:
``YES`` if the feature is fully supported by the current version of
CrateDB, ``NO`` if not
:is_verified_by:
Identifies the conformance test used to verify the claim;
Always ``NULL`` since the CrateDB development group does not perform formal
testing of feature conformance
:comments:
Either ``NULL`` or shows a comment about the supported status of the
feature
.. _character_sets:
``character_sets``
------------------
The ``character_sets`` table identifies the character sets available in the
current database.
In CrateDB there is always a single entry listing `UTF8`::
cr> SELECT character_set_name, character_repertoire FROM information_schema.character_sets;
+--------------------+----------------------+
| character_set_name | character_repertoire |
+--------------------+----------------------+
| UTF8 | UCS |
+--------------------+----------------------+
SELECT 1 row in set (... sec)
.. list-table::
:header-rows: 1
* - Column Name
- Return Type
- Description
* - ``character_set_catalog``
- ``TEXT``
- Not implemented, this column is always null.
* - ``character_set_schema``
- ``TEXT``
- Not implemented, this column is always null.
* - ``character_set_name``
- ``TEXT``
- Name of the character set
* - ``character_repertoire``
- ``TEXT``
- Character repertoire
* - ``form_of_use``
- ``TEXT``
- Character encoding form, same as ``character_set_name``
* - ``default_collate_catalog``
- ``TEXT``
- Name of the database containing the default collation (Always ``crate``)
* - ``default_collate_schema``
- ``TEXT``
- Name of the schema containing the default collation (Always ``NULL``)
* - ``default_collate_name``
- ``TEXT``
- Name of the default collation (Always ``NULL``)