← Back to Tutorials

14. Table & Columns

Data Types

CategoryTypes
NumericNUMBER, INT, FLOAT, DECIMAL
StringVARCHAR, CHAR, TEXT, STRING
Date/TimeDATE, TIME, TIMESTAMP, TIMESTAMP_LTZ, TIMESTAMP_NTZ, TIMESTAMP_TZ
Semi-structuredVARIANT, OBJECT, ARRAY
BinaryBINARY
CREATE TABLE employees (
  emp_id INT PRIMARY KEY,
  name VARCHAR(100) NOT NULL,
  salary NUMBER(10,2),
  hire_date DATE DEFAULT CURRENT_DATE,
  metadata VARIANT,
  dept_id INT,
  FOREIGN KEY (dept_id) REFERENCES departments(dept_id)
);

-- Add/drop columns
ALTER TABLE employees ADD COLUMN email VARCHAR(255);
ALTER TABLE employees DROP COLUMN email;

-- Set default
ALTER TABLE employees ALTER COLUMN salary SET DEFAULT 0;

Constraints

Snowflake supports PRIMARY KEY, UNIQUE, FOREIGN KEY, and NOT NULL. These are informational (not enforced) except NOT NULL.

✏️ Exercise: Create tables with various data types including VARIANT. Insert JSON data into the VARIANT column.