SHOW COLUMNS

Lists the columns in the tables or views and the dimensions, facts, and metrics in the semantic views for which you have access privileges. This command can be used to list the columns, dimensions, facts, and metrics for the following objects:

  • The specified table or view.

  • All tables and views in the specified schema or in the schema that is currently in use.

  • All tables and views in the specified database or in the database that is currently in use.

  • All tables and views in your account.

こちらもご参照ください。

DESCRIBE TABLE

COLUMNS ビュー (情報スキーマ)

構文

SHOW COLUMNS [ LIKE '<pattern>' ]
             [ IN { ACCOUNT | DATABASE [ <database_name> ] | SCHEMA [ <schema_name> ] | TABLE | [ TABLE ] <table_name> | VIEW | [ VIEW ] <view_name> } | APPLICATION <application_name> | APPLICATION PACKAGE <application_package_name> ]
Copy

パラメーター

LIKE '<パターン>'

オブジェクト名でコマンド出力をフィルターします。フィルターは、 SQL ワイルドカード文字(% および _)をサポートする、 大文字と小文字を区別しない パターンマッチングを使用します。

たとえば、次のパターンは同じ結果を返します。

... LIKE '%testing%' ...
... LIKE '%TESTING%' ...
IN { ACCOUNT | DATABASE [ <database_name> ] | SCHEMA [ <schema_name> ] | TABLE | [ TABLE ] <table_name> | VIEW | [ VIEW ] <view_name> | APPLICATION <application_name>  | APPLICATION PACKAGE <application_package_name> }

コマンドのスコープを指定します。これにより、コマンドが現在または指定のデータベース、スキーマ、テーブル、またはビューの記録のみをリストするか、アカウント全体の記録をリストするかを決定します。

キーワード ACCOUNT を指定すると、コマンドは、現在のアカウントのデータベースすべてにあるすべてのスキーマの記録を取得します。

キーワード DATABASE を指定すると、次のようになります。

  • db_name を指定すると、コマンドは、指定されたデータベースのスキーマすべての記録を取得します。

  • :samp:`{db_name}`を指定しない場合、以下のようになります:

    • 現在のデータベースがある場合、コマンドは、現在のデータベースにあるスキーマすべての記録を取得します。

    • 現在のデータベースがない場合、コマンドは、アカウントにあるすべてのデータベースとスキーマの記録を取得します。

キーワード SCHEMA を指定すると、次のようになります。

  • 修飾されたスキーマ名(例: my_database.my_schema)を指定すると、コマンドは、指定されたデータベースとスキーマの記録を取得します。

  • 修飾されていない schema_name を指定すると、次のようになります。

    • 現在のデータベースがある場合、コマンドは、現在のデータベースにある指定されたスキーマの記録を取得します。

    • 現在のデータベースがない場合、コマンドは、エラー SQL compilation error: Object does not exist, or operation cannot be performed を表示します。

  • :samp:`{schema_name}`を指定しない場合、以下のようになります:

    • 現在のデータベースがある場合は、次のようになります。

      • 現在のスキーマがある場合、コマンドは、現在のデータベースにある現在のスキーマの記録を取得します。

      • 現在のスキーマがない場合、コマンドは、現在のデータベースにあるスキーマすべての記録を取得します。

    • 現在のデータベースがない場合、コマンドは、アカウントにあるすべてのデータベースとすべてのスキーマの記録を取得します。

table_name なしでキーワード TABLE を指定すると、次のようになります。

  • 現在のデータベースがある場合は、次のようになります。

    • 現在のスキーマがある場合、コマンドは、現在のデータベースにある現在のスキーマの記録を取得します。

    • 現在のスキーマがない場合、コマンドは、現在のデータベースにあるスキーマすべての記録を取得します。

  • 現在のデータベースがない場合、コマンドは、アカウントにあるすべてのデータベースとすべてのスキーマの記録を取得します。

<テーブル名> (キーワード TABLE の有無にかかわらず)を指定すると、次のようになります。

  • 完全修飾された <テーブル名> (例: my_database_name.my_schema_name.my_table_name)を指定すると、コマンドは指定されたテーブルのすべての記録を取得します。

  • スキーマ修飾された <テーブル名> (例: my_schema_name.my_table_name)を指定すると、次のようになります。

    • 現在のデータベースが存在する場合、コマンドは、指定されたテーブルのすべての記録を取得します。

    • 現在のデータベースが存在しない場合、コマンドは Cannot perform SHOW <オブジェクト型>.This session does not have a current database... のようなエラーを表示します。

  • 修飾されていない <テーブル名> を指定すると、次のようになります。

    • 現在のデータベースと現在のスキーマが存在する場合、コマンドは、現在のデータベースにおける現在のスキーマで指定されたテーブルの記録を取得します。

    • 現在のデータベースが存在しないか、現在のスキーマが存在しない場合、コマンドは、 SQL compilation error: <オブジェクト> does not exist or not authorized. のようなエラーを表示します。

If you specify the VIEW keyword or a view name, the rules for views parallel the rules for tables.

If you specify the APPLICATION or APPLICATION PACKAGE keywords, records for the specified Snowflake Native App Framework application or application package are returned.

デフォルト: セッションで現在使用中のデータベースがあるかどうかによって異なります。

  • データベース: DATABASE がデフォルトです(つまり、コマンドはデータベースで表示する権限を持つオブジェクトを返します)。

  • データベースなし: ACCOUNT はデフォルトです(つまり、コマンドは、アカウントで表示する権限を持つオブジェクトを返します)。

使用上の注意

  • You can use the VIEW keyword and specify a view name for standard views, materialized views, and semantic views.

  • コマンドは、コマンドを実行するために使用されるロールのアクセス権限によって決定された通り、指定されたオブジェクトタイプに対して 最大 1万件の記録を返します。1万件を超える記録は、フィルターを適用しても返されません。

    1万件を超える記録が存在する結果を表示するには、 Snowflake Information Schema で対応するビュー(存在する場合)をクエリします。

  • このコマンドの実行には、稼働中のウェアハウスは必要ありません。

  • このコマンドは、現在のユーザーの現在のロールに少なくとも1つのアクセス権限が付与されているオブジェクトのみを返します。

  • MANAGE GRANTS アクセス権限により、所有者はアカウント内のすべてのオブジェクトを暗黙的に参照できます。デフォルトでは、アカウント管理者( ACCOUNTADMIN ロールを持つユーザー)とセキュリティ管理者( SECURITYADMIN ロールを持つユーザー)のみが MANAGE GRANTS 権限を持っています。

  • このコマンドの出力を後処理するには、 パイプ演算子->>)または RESULT_SCAN 関数。どちらのコンストラクトも、出力を クエリできる結果セットとして扱います。

    For example, you can use the pipe operator or RESULT_SCAN function to select specific columns from the SHOW command output or filter the rows.

    When you refer to the output columns, use double-quoted identifiers for the column names. For example, to select the output column type, specify SELECT "type".

    You must use double-quoted identifiers because the output column names for SHOW commands are in lowercase. The double quotes ensure that the column names in the SELECT list or WHERE clause match the column names in the SHOW command output that was scanned.

注釈

The column names in the output table for the SHOW COLUMNS command are lowercase (that is, table_name, schema_name, column_name, and so on). However, the values in the column_name column reflect the column name that is stored. For example, if a column name is added without being enclosed in double quotes using the ALTER TABLE ... ADD COLUMN MYCOLUMN statement, the column name is stored in uppercase and appears as MYCOLUMN in the column_name column.

出力

コマンド出力は、次の列の列プロパティとメタデータを提供します。

説明

table_name

Name of the table or view that the column, dimension, fact, or metric belongs to.

schema_name

テーブルのスキーマ。

column_name

Name of the column, dimension, fact, or metric.

data_type

JSON object containing the data type and applicable properties of the column, dimension, fact, or metric.

The type key-value pair specifies the data type of the column, dimension, fact, or metric.

For string and numeric data types, type specifies one of the following values:

  • TEXT for all string types.

  • FIXED for all fixed-point numeric types.

  • REAL for all floating-point numeric types.

The other key-value pairs describe the properties that are applicable to the particular data type. For example:

  • If type is TEXT or BINARY, the additional key-value pairs can include length, byteLength, nullable, and fixed.

  • If type is FIXED, TIME, TIMESTAMP_NTZ, TIMESTAMP_LTZ, or TIMESTAMP_TZ, the additional key-value pairs can include precision, scale, and nullable.

  • If type is REAL, DATE, or BOOLEAN, the additional key-value pairs can include nullable.

null?

列に NULL 値を含めることができるかどうか。

default

列に定義されているデフォルト値(ある場合)。

kind

One of the following values:

  • COLUMN for columns in tables, views, and materialized views.

  • DIMENSION for dimensions in semantic views.

  • FACT for facts in semantic views.

  • METRIC for metrics in semantic views.

expression

comment

Comment, if any, for the column, dimension, fact, or metric.

database_name

テーブルのデータベース。

autoincrement

列の開始値と増分値(存在する場合)の自動増分。列が NOORDER プロパティを持つ場合は、値に NOORDER が含まれます(例: IDENTITY START 1 INCREMENT 1 NOORDER)。それ以外の場合は値に ORDER が含まれます。

schema_evolution_record

指定されたテーブルの列に対してトリガーされた最新のスキーマ進化に関する情報を記録します。この列には以下のサブフィールドが含まれています。

  • EvolutionType: トリガーされたスキーマ進化のタイプ (ADD_COLUMN または DROP_NOT_NULL)。

  • EvolutionMode: トリガーとなる摂取メカニズム (COPY または SNOWPIPE)。

  • FileName: 進化のトリガーとなったファイル名。

  • TriggeringTime: 列が進化したおおよその時間。

  • QueryId または PipeID: トリガーとなるクエリまたはパイプの一意な識別子 (COPY の場合は QUERY ID 、 SNOWPIPE の場合は PIPE ID)。

The following example creates a table and then runs the SHOW COLUMNS command to list the columns in the table:

CREATE OR REPLACE TABLE test_show_columns (
  n1 NUMBER DEFAULT 5,
  n2_int INTEGER DEFAULT n1+5,
  n3_bigint BIGINT AUTOINCREMENT,
  n4_dec DECIMAL IDENTITY (1,10),
  f1 FLOAT,
  f2_double DOUBLE,
  f3_real REAL,
  s1 STRING,
  s2_var VARCHAR,
  s3_char CHAR,
  s4_text TEXT,
  "s5_case_sensitive" VARCHAR,
  b1 BINARY,
  b2_var VARBINARY,
  bool1 BOOLEAN,
  d1 DATE,
  t1 TIME,
  ts1 TIMESTAMP,
  ts2_ltz TIMESTAMP_LTZ,
  ts3_ntz TIMESTAMP_NTZ,
  ts4_tz TIMESTAMP_TZ);

SHOW COLUMNS IN TABLE test_show_columns;
Copy
+-------------------+----------------+-------------------+---------------------------------------------------------------------------------------+-------+--------------------------+--------+------------+---------+---------------+---------------------------------------+-------------------------+
| table_name        | schema_name    | column_name       | data_type                                                                             | null? | default                  | kind   | expression | comment | database_name | autoincrement                         | schema_evolution_record |
|-------------------+----------------+-------------------+---------------------------------------------------------------------------------------+-------+--------------------------+--------+------------+---------+---------------+---------------------------------------+-------------------------|
| TEST_SHOW_COLUMNS | MY_SCHEMA      | N1                | {"type":"FIXED","precision":38,"scale":0,"nullable":true}                             | true  | 5                        | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | N2_INT            | {"type":"FIXED","precision":38,"scale":0,"nullable":true}                             | true  | TEST_SHOW_COLUMNS.N1 + 5 | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | N3_BIGINT         | {"type":"FIXED","precision":38,"scale":0,"nullable":true}                             | true  |                          | COLUMN |            |         | MY_DB         | IDENTITY START 1 INCREMENT 1 NOORDER  | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | N4_DEC            | {"type":"FIXED","precision":38,"scale":0,"nullable":true}                             | true  |                          | COLUMN |            |         | MY_DB         | IDENTITY START 1 INCREMENT 10 NOORDER | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | F1                | {"type":"REAL","nullable":true}                                                       | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | F2_DOUBLE         | {"type":"REAL","nullable":true}                                                       | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | F3_REAL           | {"type":"REAL","nullable":true}                                                       | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | S1                | {"type":"TEXT","length":16777216,"byteLength":16777216,"nullable":true,"fixed":false} | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | S2_VAR            | {"type":"TEXT","length":16777216,"byteLength":16777216,"nullable":true,"fixed":false} | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | S3_CHAR           | {"type":"TEXT","length":1,"byteLength":4,"nullable":true,"fixed":false}               | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | S4_TEXT           | {"type":"TEXT","length":16777216,"byteLength":16777216,"nullable":true,"fixed":false} | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | s5_case_sensitive | {"type":"TEXT","length":16777216,"byteLength":16777216,"nullable":true,"fixed":false} | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | B1                | {"type":"BINARY","length":8388608,"byteLength":8388608,"nullable":true,"fixed":true}  | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | B2_VAR            | {"type":"BINARY","length":8388608,"byteLength":8388608,"nullable":true,"fixed":false} | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | BOOL1             | {"type":"BOOLEAN","nullable":true}                                                    | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | D1                | {"type":"DATE","nullable":true}                                                       | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | T1                | {"type":"TIME","precision":0,"scale":9,"nullable":true}                               | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | TS1               | {"type":"TIMESTAMP_NTZ","precision":0,"scale":9,"nullable":true}                      | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | TS2_LTZ           | {"type":"TIMESTAMP_LTZ","precision":0,"scale":9,"nullable":true}                      | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | TS3_NTZ           | {"type":"TIMESTAMP_NTZ","precision":0,"scale":9,"nullable":true}                      | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
| TEST_SHOW_COLUMNS | MY_SCHEMA      | TS4_TZ            | {"type":"TIMESTAMP_TZ","precision":0,"scale":9,"nullable":true}                       | true  |                          | COLUMN |            |         | MY_DB         |                                       | NULL                    |
+-------------------+----------------+-------------------+---------------------------------------------------------------------------------------+-------+--------------------------+--------+------------+---------+---------------+---------------------------------------+-------------------------+