github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/vtable/information_schema.go (about) 1 // Copyright 2018 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package vtable 12 13 // InformationSchemaColumns describes the schema of the 14 // information_schema.columns table. 15 // Postgres: https://www.postgresql.org/docs/9.6/static/infoschema-columns.html 16 // MySQL: https://dev.mysql.com/doc/refman/5.7/en/columns-table.html 17 const InformationSchemaColumns = ` 18 CREATE TABLE information_schema.columns ( 19 TABLE_CATALOG STRING NOT NULL, 20 TABLE_SCHEMA STRING NOT NULL, 21 TABLE_NAME STRING NOT NULL, 22 COLUMN_NAME STRING NOT NULL, 23 ORDINAL_POSITION INT NOT NULL, 24 COLUMN_DEFAULT STRING, 25 IS_NULLABLE STRING NOT NULL, 26 DATA_TYPE STRING NOT NULL, 27 CHARACTER_MAXIMUM_LENGTH INT, 28 CHARACTER_OCTET_LENGTH INT, 29 NUMERIC_PRECISION INT, 30 NUMERIC_PRECISION_RADIX INT, 31 NUMERIC_SCALE INT, 32 DATETIME_PRECISION INT, 33 INTERVAL_TYPE STRING, 34 INTERVAL_PRECISION INT, 35 CHARACTER_SET_CATALOG STRING, 36 CHARACTER_SET_SCHEMA STRING, 37 CHARACTER_SET_NAME STRING, 38 COLLATION_CATALOG STRING, 39 COLLATION_SCHEMA STRING, 40 COLLATION_NAME STRING, 41 DOMAIN_CATALOG STRING, 42 DOMAIN_SCHEMA STRING, 43 DOMAIN_NAME STRING, 44 UDT_CATALOG STRING, 45 UDT_SCHEMA STRING, 46 UDT_NAME STRING, 47 SCOPE_CATALOG STRING, 48 SCOPE_SCHEMA STRING, 49 SCOPE_NAME STRING, 50 MAXIMUM_CARDINALITY INT, 51 DTD_IDENTIFIER STRING, 52 IS_SELF_REFERENCING STRING, 53 IS_IDENTITY STRING, 54 IDENTITY_GENERATION STRING, 55 IDENTITY_START STRING, 56 IDENTITY_INCREMENT STRING, 57 IDENTITY_MAXIMUM STRING, 58 IDENTITY_MINIMUM STRING, 59 IDENTITY_CYCLE STRING, 60 IS_GENERATED STRING, 61 GENERATION_EXPRESSION STRING, -- MySQL/CockroachDB extension. 62 IS_UPDATABLE STRING, 63 IS_HIDDEN STRING NOT NULL, -- CockroachDB extension for SHOW COLUMNS / dump. 64 CRDB_SQL_TYPE STRING NOT NULL -- CockroachDB extension for SHOW COLUMNS / dump. 65 )` 66 67 // InformationSchemaAdministrableRoleAuthorizations describes the schema of the 68 // information_schema.administrable_role_authorizations table. 69 // Postgres: https://www.postgresql.org/docs/9.6/static/infoschema-administrable-role-authorizations.html 70 // MySQL: missing 71 const InformationSchemaAdministrableRoleAuthorizations = ` 72 CREATE TABLE information_schema.administrable_role_authorizations ( 73 GRANTEE STRING NOT NULL, 74 ROLE_NAME STRING NOT NULL, 75 IS_GRANTABLE STRING NOT NULL 76 )` 77 78 // InformationSchemaApplicableRoles describes the schema of the 79 // information_schema.applicable_roles table. 80 // Postgres: https://www.postgresql.org/docs/9.6/static/infoschema-applicable-roles.html 81 // MySQL: missing 82 const InformationSchemaApplicableRoles = ` 83 CREATE TABLE information_schema.applicable_roles ( 84 GRANTEE STRING NOT NULL, 85 ROLE_NAME STRING NOT NULL, 86 IS_GRANTABLE STRING NOT NULL 87 )` 88 89 // InformationSchemaCheckConstraints describes the schema of the 90 // information_schema.check_constraints table. 91 // Postgres: https://www.postgresql.org/docs/9.6/static/infoschema-check-constraints.html 92 // MySQL: missing 93 const InformationSchemaCheckConstraints = ` 94 CREATE TABLE information_schema.check_constraints ( 95 CONSTRAINT_CATALOG STRING NOT NULL, 96 CONSTRAINT_SCHEMA STRING NOT NULL, 97 CONSTRAINT_NAME STRING NOT NULL, 98 CHECK_CLAUSE STRING NOT NULL 99 )` 100 101 // InformationSchemaColumnPrivileges describes the schema of the 102 // information_schema.column_privileges table. 103 // Postgres: https://www.postgresql.org/docs/9.6/static/infoschema-column-privileges.html 104 // MySQL: https://dev.mysql.com/doc/refman/5.7/en/column-privileges-table.html 105 const InformationSchemaColumnPrivileges = ` 106 CREATE TABLE information_schema.column_privileges ( 107 GRANTOR STRING, 108 GRANTEE STRING NOT NULL, 109 TABLE_CATALOG STRING NOT NULL, 110 TABLE_SCHEMA STRING NOT NULL, 111 TABLE_NAME STRING NOT NULL, 112 COLUMN_NAME STRING NOT NULL, 113 PRIVILEGE_TYPE STRING NOT NULL, 114 IS_GRANTABLE STRING 115 )` 116 117 // InformationSchemaSchemata describes the schema of the 118 // information_schema.schemata table. 119 const InformationSchemaSchemata = ` 120 CREATE TABLE information_schema.schemata ( 121 CATALOG_NAME STRING NOT NULL, 122 SCHEMA_NAME STRING NOT NULL, 123 DEFAULT_CHARACTER_SET_NAME STRING, 124 SQL_PATH STRING 125 )` 126 127 // InformationSchemaTables describes the schema of the 128 // information_schema.tables table. 129 // Postgres: https://www.postgresql.org/docs/9.6/static/infoschema-tables.html 130 // MySQL: https://dev.mysql.com/doc/refman/5.7/en/tables-table.html 131 const InformationSchemaTables = ` 132 CREATE TABLE information_schema.tables ( 133 TABLE_CATALOG STRING NOT NULL, 134 TABLE_SCHEMA STRING NOT NULL, 135 TABLE_NAME STRING NOT NULL, 136 TABLE_TYPE STRING NOT NULL, 137 IS_INSERTABLE_INTO STRING NOT NULL, 138 VERSION INT, 139 INDEX(TABLE_NAME) 140 )`