A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/developer-guide/python-connector/../../sql-reference/sql/desc-table below:

Website Navigation


DESCRIBE TABLE | Snowflake Documentation

DESCRIBE TABLE

Describes either the columns in a table or the set of stage properties for the table (current values and default values).

DESCRIBE can be abbreviated to DESC.

See also:

DROP TABLE , ALTER TABLE , CREATE TABLE , SHOW TABLES

DESCRIBE VIEW

Syntax
{ DESCRIBE | DESC } TABLE <name> [ TYPE =  { COLUMNS | STAGE } ]

Copy

Parameters
name

Specifies the identifier for the table to describe. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive.

TYPE = COLUMNS | STAGE

Specifies whether to display the columns for the table or the set of stage properties for the table (current values and default values).

Default: TYPE = COLUMNS

Usage notes Output

When TYPE = COLUMNS, the command output provides the following properties and metadata:

Column

Description

name

Name of the column in the table.

type

Data type of the column in the table. If collation has been specified for the column, the collation specification is included.

kind

This value is always COLUMN for Snowflake tables.

null?

Whether the column accepts NULL values (Y or N).

default

The default value for the column, if any (otherwise NULL).

primary key

Whether the column is the primary key (or part of a multi-column primary key; Y or N).

unique key

Whether the column has a UNIQUE constraint (Y or N).

check

Reserved for future use.

expression

Reserved for future use.

comment

The comment set for the column, if any (otherwise NULL).

policy name

The masking policy set for the column, if any (otherwise NULL).

privacy domain

The privacy domain set for the column, if any (otherwise NULL).

schema evolution record

Records information about the latest triggered Schema Evolution for a given table column. This column contains the following subfields:

When TYPE = STAGE, the command output provides the current and default values for the table’s stage properties. See Example: Describe stage properties.

Examples

The following examples show how to describe tables.

Example: Describe a table that has constraints and other column attributes

Create a table with five columns, two with constraints. Give one column a DEFAULT value and a comment.

CREATE OR REPLACE TABLE desc_example(
  c1 INT PRIMARY KEY,
  c2 INT,
  c3 INT UNIQUE,
  c4 VARCHAR(30) DEFAULT 'Not applicable' COMMENT 'This column is rarely populated',
  c5 VARCHAR(100));

Copy

Describe the columns in the table:

DESCRIBE TABLE desc_example;

Copy

+------+--------------+--------+-------+------------------+-------------+------------+-------+------------+---------------------------------+-------------+----------------+-------------------------+
| name | type         | kind   | null? | default          | primary key | unique key | check | expression | comment                         | policy name | privacy domain | schema evolution record |
|------+--------------+--------+-------+------------------+-------------+------------+-------+------------+---------------------------------+-------------+----------------+-------------------------|
| C1   | NUMBER(38,0) | COLUMN | N     | NULL             | Y           | N          | NULL  | NULL       | NULL                            | NULL        | NULL           | NULL                    |
| C2   | NUMBER(38,0) | COLUMN | Y     | NULL             | N           | N          | NULL  | NULL       | NULL                            | NULL        | NULL           | NULL                    |
| C3   | NUMBER(38,0) | COLUMN | Y     | NULL             | N           | Y          | NULL  | NULL       | NULL                            | NULL        | NULL           | NULL                    |
| C4   | VARCHAR(30)  | COLUMN | Y     | 'Not applicable' | N           | N          | NULL  | NULL       | This column is rarely populated | NULL        | NULL           | NULL                    |
| C5   | VARCHAR(100) | COLUMN | Y     | NULL             | N           | N          | NULL  | NULL       | NULL                            | NULL        | NULL           | NULL                    |
+------+--------------+--------+-------+------------------+-------------+------------+-------+------------+---------------------------------+-------------+----------------+-------------------------+
Example: Describe a table that has a masking policy on a column

Create a normal masking policy, then recreate the desc_example table with the masking policy set on one column. (To run this example, create the email_mask masking policy first.)

CREATE OR REPLACE TABLE desc_example(
  c1 INT PRIMARY KEY,
  c2 INT,
  c3 INT UNIQUE,
  c4 VARCHAR(30) DEFAULT 'Not applicable' COMMENT 'This column is rarely populated',
  c5 VARCHAR(100) WITH MASKING POLICY email_mask);

Copy

+------+--------------+--------+-------+------------------+-------------+------------+-------+------------+---------------------------------+---------------------------------+----------------+-------------------------+
| name | type         | kind   | null? | default          | primary key | unique key | check | expression | comment                         | policy name                     | privacy domain | schema evolution record |
|------+--------------+--------+-------+------------------+-------------+------------+-------+------------+---------------------------------+---------------------------------+----------------|-------------------------|
| C1   | NUMBER(38,0) | COLUMN | N     | NULL             | Y           | N          | NULL  | NULL       | NULL                            | NULL                            | NULL           | NULL                    |
| C2   | NUMBER(38,0) | COLUMN | Y     | NULL             | N           | N          | NULL  | NULL       | NULL                            | NULL                            | NULL           | NULL                    |
| C3   | NUMBER(38,0) | COLUMN | Y     | NULL             | N           | Y          | NULL  | NULL       | NULL                            | NULL                            | NULL           | NULL                    |
| C4   | VARCHAR(30)  | COLUMN | Y     | 'Not applicable' | N           | N          | NULL  | NULL       | This column is rarely populated | NULL                            | NULL           | NULL                    |
| C5   | VARCHAR(100) | COLUMN | Y     | NULL             | N           | N          | NULL  | NULL       | NULL                            | HT_SENSORS.HT_SCHEMA.EMAIL_MASK | NULL           | NULL                    |
+------+--------------+--------+-------+------------------+-------------+------------+-------+------------+---------------------------------+---------------------------------+----------------+-------------------------+
Example: Describe stage properties

Describe the current stage properties for the same table (only the first five rows are shown here):

DESCRIBE TABLE desc_example TYPE = STAGE;

Copy

+--------------------+--------------------------------+---------------+-----------------+------------------+
| parent_property    | property                       | property_type | property_value  | property_default |
|--------------------+--------------------------------+---------------+-----------------+------------------|
| STAGE_FILE_FORMAT  | TYPE                           | String        | CSV             | CSV              |
| STAGE_FILE_FORMAT  | RECORD_DELIMITER               | String        | \n              | \n               |
| STAGE_FILE_FORMAT  | FIELD_DELIMITER                | String        | ,               | ,                |
| STAGE_FILE_FORMAT  | FILE_EXTENSION                 | String        |                 |                  |
| STAGE_FILE_FORMAT  | SKIP_HEADER                    | Integer       | 0               | 0                |
...

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4