Choose the source
FROM identifies the table or result to process.
Find SQL by task, from queries and aggregation to COPY INTO, updates, object definitions and access control. Compare Snowflake and BigQuery syntax, prerequisites and effects.
Includes 23 query comparison groups and 22 operation topics. “Examples” means representative examples, not every option or every product command.
Operations checked: 2026-10-06
| Area | Syntax and features | Coverage | Official references |
|---|---|---|---|
| Queries and analysis | SELECT / JOIN / GROUP BY / WINDOW | Representative examples | Snowflake · BigQuery |
| Loading and exporting | COPY INTO / LOAD DATA / EXPORT DATA | Representative examples | Snowflake · BigQuery |
| Data manipulation | INSERT / UPDATE / DELETE / MERGE / TRUNCATE | Representative examples | Snowflake · BigQuery |
| Object definitions | TABLE / VIEW / SCHEMA / FUNCTION / PROCEDURE | Representative examples | Snowflake · BigQuery |
| Transactions, access and scripting | TRANSACTION / GRANT / REVOKE / DECLARE / INFORMATION_SCHEMA | Representative examples | Snowflake · BigQuery |
| Automation and pipelines | PIPE / STREAM / TASK / DYNAMIC TABLE / scheduled queries | Official reference only | Snowflake · BigQuery |
| External and specialized tables | EXTERNAL TABLE / ICEBERG / SNAPSHOT / CLONE / MATERIALIZED VIEW | Official reference only | Snowflake · BigQuery |
| Accounts and compute | ACCOUNT / USER / ROLE / WAREHOUSE / IAM / reservations | Official reference only | Snowflake · BigQuery |
| Security and sharing | POLICY / MASKING / ROW ACCESS / sharing / connections | Official reference only | Snowflake · BigQuery |
| ML and product extensions | ML / Cortex / search indexes / vector indexes / applications | Official reference only | Snowflake · BigQuery |
COPY INTO <table> / LOAD DATA INTOCOPY INTO <location> / EXPORT DATACREATE STAGE / FROM FILESVALIDATION_MODE / LOAD DATAINSERT INTO / INSERT INTOUPDATE / UPDATEDELETE FROM / DELETE FROMMERGE INTO / MERGE INTOTRUNCATE TABLE / TRUNCATE TABLECREATE TABLE / CREATE TABLECREATE TABLE AS SELECT / CREATE TABLE AS SELECTCREATE VIEW / CREATE VIEWALTER TABLE / ALTER TABLEDROP TABLE / DROP TABLEBEGIN TRANSACTION / BEGIN TRANSACTIONGRANT / GRANTREVOKE / REVOKECREATE SCHEMA / CREATE SCHEMASHOW TABLES / INFORMATION_SCHEMADECLARE / DECLARECREATE FUNCTION / CREATE FUNCTIONCREATE PROCEDURE / CREATE PROCEDURECovers queries and common operational statements. The coverage table distinguishes examples from reference-only areas.
FROM identifies the table or result to process.
WITH and a subquery in FROM can express the same intermediate result.
Matches / all left / all from both / every combination.
In a LEFT JOIN, moving the condition changes which rows survive.
Expand elements of a composite value into more rows.
WHERE before aggregation; HAVING after aggregation; QUALIFY after windows.
Choose what to count or which summary to calculate.
WITHIN GROUP orders aggregate inputs; BigQuery places ORDER BY inside aggregate arguments.
Control duplicate values, NULLs, maximum-scoring rows and input limits within aggregate calls.
GROUP BY defines aggregation units; DISTINCT removes duplicate selected rows.
Aggregate: N rows → one per group. Window: N rows → N rows.
Unique sequence / ties with gaps / ties without gaps.
Attach the preceding and following values in the same order.
IGNORE / RESPECT NULLS controls values seen by a function; NULLS FIRST / LAST controls row ordering.
ROWS uses row positions; RANGE uses ordering values.
Comparisons return TRUE, FALSE or NULL; logical operators combine them.
Equality with NULL is unknown. Test with IS NULL.
CASE supports multiple conditions; IF / IFF is compact for two outcomes.
Unconvertible value: CAST errors; the safe version returns NULL.
ABS returns magnitude; ROUND rounds to the specified precision.
Apply four operations to the same string.
The operation is shared; argument order and unit syntax differ.
Both may display 7, but their types differ.
One A and B: keep duplicates / remove them / common values / left only.
Match names even when column positions differ.
Deduplicate → sort → skip initial rows → take up to the limit.
Snowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Prepare an empty orders table and a CSV with an id,amount header. Upload it to Snowflake internal stage csv_stage, or to compatible-location Cloud Storage for BigQuery. Replace YOUR_BUCKET.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
COPY INTO tbi_lab.orders
FROM @tbi_lab.csv_stage/orders.csv
FILE_FORMAT = (TYPE = CSV SKIP_HEADER = 1)
ON_ERROR = 'ABORT_STATEMENT';Loads file rows into the table. Inspect the load result and target rows.
SELECT id, amount FROM tbi_lab.orders ORDER BY id;ON_ERROR controls failures; ABORT_STATEMENT stops the statement. Load history may skip previously loaded files on a rerun. FORCE=TRUE can duplicate data.
Official sources · Snowflake 1
# load-filesSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Prepare the two-row orders table and a writable destination: csv_stage for Snowflake, or Cloud Storage with YOUR_BUCKET replaced for BigQuery.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
COPY INTO @tbi_lab.csv_stage/export_run/
FROM (SELECT id, amount FROM tbi_lab.orders)
FILE_FORMAT = (TYPE = CSV)
HEADER = TRUE;Writes query results to CSV files. Inspect the destination files.
LIST @tbi_lab.csv_stage/export_run/;Use a fresh destination each time. Output may span multiple files. Check file counts and contents at the destination.
Official sources · Snowflake 1
# unload-filesSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Prepare tbi_lab and the required create/read permissions.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
CREATE FILE FORMAT tbi_lab.csv_format
TYPE = CSV SKIP_HEADER = 1;
CREATE STAGE tbi_lab.csv_stage
FILE_FORMAT = (FORMAT_NAME = 'tbi_lab.csv_format');Creates an empty internal stage and a CSV format in Snowflake.
LIST @tbi_lab.csv_stage;Creating a stage does not upload files. Upload orders.csv in Snowsight or a PUT-capable client. PUT targets internal stages.
Official sources · Snowflake 1 · Snowflake 2 · Snowflake 3
# stage-formatSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Prepare an empty orders table and a CSV with an id,amount header. Upload it to Snowflake internal stage csv_stage, or to compatible-location Cloud Storage for BigQuery. Replace YOUR_BUCKET.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
COPY INTO tbi_lab.orders
FROM @tbi_lab.csv_stage/orders.csv
FILE_FORMAT = (TYPE = CSV SKIP_HEADER = 1)
VALIDATION_MODE = 'RETURN_ERRORS';In Snowflake, returns file errors without inserting rows.
SELECT id, amount FROM tbi_lab.orders ORDER BY id;VALIDATION_MODE validates without loading. It cannot be combined with a transformation SELECT. Fix errors before a normal COPY.
Official sources · Snowflake 1
# validate-loadSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Start with tbi_lab.orders(id, amount) containing (1,100) and (2,200). Restore this initial state for each example; these are not sequential steps.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
INSERT INTO tbi_lab.orders (id, amount)
VALUES (3, 300);Adds id=3, amount=300.
SELECT id, amount FROM tbi_lab.orders ORDER BY id;Official sources · Snowflake 1
# insert-rowsSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Start with tbi_lab.orders(id, amount) containing (1,100) and (2,200). Restore this initial state for each example; these are not sequential steps.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
UPDATE tbi_lab.orders SET amount = 150 WHERE id = 1;Changes amount to 150 for id=1.
SELECT id, amount FROM tbi_lab.orders ORDER BY id;Preview affected rows using SELECT with the same WHERE. BigQuery requires WHERE for UPDATE and DELETE.
Official sources · Snowflake 1
# update-rowsSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Start with tbi_lab.orders(id, amount) containing (1,100) and (2,200). Restore this initial state for each example; these are not sequential steps.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
DELETE FROM tbi_lab.orders WHERE id = 2;Removes the row with id=2.
SELECT id, amount FROM tbi_lab.orders ORDER BY id;Preview affected rows using SELECT with the same WHERE. BigQuery requires WHERE for UPDATE and DELETE.
Official sources · Snowflake 1
# delete-rowsSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Start with tbi_lab.orders(id, amount) containing (1,100) and (2,200). Restore this initial state for each example; these are not sequential steps.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
MERGE INTO tbi_lab.orders AS t
USING (SELECT 1 AS id, 150 AS amount
UNION ALL SELECT 3, 300) AS s
ON t.id = s.id
WHEN MATCHED THEN UPDATE SET amount = s.amount
WHEN NOT MATCHED THEN INSERT (id, amount)
VALUES (s.id, s.amount);Updates id=1 to 150 and inserts id=3 with 300.
SELECT id, amount FROM tbi_lab.orders ORDER BY id;Check that multiple source rows do not match one update target key. Duplicate-match behavior depends on product and action.
Official sources · Snowflake 1
# merge-rowsSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Start with tbi_lab.orders(id, amount) containing (1,100) and (2,200). Restore this initial state for each example; these are not sequential steps.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
TRUNCATE TABLE tbi_lab.orders;Leaves zero rows while keeping the column definitions.
SELECT COUNT(*) AS rows_left FROM tbi_lab.orders;Targets every row; there is no WHERE filter.
Official sources · Snowflake 1
# truncate-tableSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Create tbi_lab first and ensure the new object name is unused.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
CREATE TABLE tbi_lab.orders (id INTEGER, amount NUMBER(12,2));Creates an empty table with id and amount columns.
DESCRIBE TABLE tbi_lab.orders;These examples do not use OR REPLACE to overwrite existing data.
Official sources · Snowflake 1
# create-tableSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Start with tbi_lab.orders(id, amount) containing (1,100) and (2,200). Restore this initial state for each example; these are not sequential steps.
Create tbi_lab first and ensure the new object name is unused.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
CREATE TABLE tbi_lab.large_orders AS
SELECT id, amount FROM tbi_lab.orders WHERE amount >= 200;Saves rows with amount >= 200 in a new table.
SELECT * FROM tbi_lab.large_orders ORDER BY id;These examples do not use OR REPLACE to overwrite existing data.
Official sources · Snowflake 1
# create-as-selectSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Start with tbi_lab.orders(id, amount) containing (1,100) and (2,200). Restore this initial state for each example; these are not sequential steps.
Create tbi_lab first and ensure the new object name is unused.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
CREATE VIEW tbi_lab.large_orders_view AS
SELECT id, amount FROM tbi_lab.orders WHERE amount >= 200;Stores a query definition. A regular view does not retain a copy of the result rows.
SELECT * FROM tbi_lab.large_orders_view ORDER BY id;ALTER VIEW and DROP VIEW change or remove the view definition. Check dependencies on source tables.
Official sources · Snowflake 1
# create-viewSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Start with tbi_lab.orders(id, amount) containing (1,100) and (2,200). Restore this initial state for each example; these are not sequential steps.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
ALTER TABLE tbi_lab.orders ADD COLUMN note VARCHAR;Adds note; existing rows have NULL in this column.
DESCRIBE TABLE tbi_lab.orders;This example adds a column. Dropping columns or changing types needs a separate data and dependency check.
Official sources · Snowflake 1
# alter-tableSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Start with tbi_lab.orders(id, amount) containing (1,100) and (2,200). Restore this initial state for each example; these are not sequential steps.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
DROP TABLE tbi_lab.orders;Removes the table definition and its data.
SHOW TABLES LIKE 'ORDERS' IN SCHEMA tbi_lab;Recovery depends on product retention settings. Do not assume this operation is recoverable.
Official sources · Snowflake 1
# drop-tableSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
CREATE SCHEMA tbi_lab;
USE SCHEMA tbi_lab;Creates tbi_lab as a container for objects.
SELECT CURRENT_DATABASE(), CURRENT_SCHEMA();Creates a schema in the current database. USE SCHEMA changes the default namespace.
Official sources · Snowflake 1 · Snowflake 2
# namespaceSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Create tbi_lab first and ensure the new object name is unused.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
CREATE FUNCTION tbi_lab.add_one(x INTEGER)
RETURNS INTEGER LANGUAGE SQL
AS $$ x + 1 $$;Creates a function that adds one to its argument.
SELECT tbi_lab.add_one(2) AS result;Official sources · Snowflake 1
# user-functionSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Create tbi_lab first and ensure the new object name is unused.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
CREATE PROCEDURE tbi_lab.answer()
RETURNS INTEGER LANGUAGE SQL
AS $$
BEGIN
RETURN 3;
END;
$$;Creates a procedure that returns 3 when called.
CALL tbi_lab.answer();Official sources · Snowflake 1
# procedureSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Start with tbi_lab.orders(id, amount) containing (1,100) and (2,200). Restore this initial state for each example; these are not sequential steps.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
BEGIN TRANSACTION;
UPDATE tbi_lab.orders SET amount = 150 WHERE id = 1;
ROLLBACK;This example rolls back: id=1 still has amount=100.
SELECT id, amount FROM tbi_lab.orders ORDER BY id;COMMIT persists changes; ROLLBACK cancels them. Snowflake DDL implicitly commits an active transaction, so do not add DDL to this example.
Official sources · Snowflake 1
# transactionSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Requires orders and authority to change access. Prepare the Snowflake tbi_reader role or verify the BigQuery recipient group.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
GRANT SELECT ON TABLE tbi_lab.orders TO ROLE tbi_reader;Grants the recipient permission to read the table.
SHOW GRANTS ON TABLE tbi_lab.orders;Table SELECT alone may not suffice. Also check database/schema USAGE and warehouse access.
Official sources · Snowflake 1
# permissions-grantSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Requires orders and authority to change access. Prepare the Snowflake tbi_reader role or verify the BigQuery recipient group.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
REVOKE SELECT ON TABLE tbi_lab.orders FROM ROLE tbi_reader;Removes the specified direct grant; access from other paths may remain.
SHOW GRANTS ON TABLE tbi_lab.orders;This REVOKE does not remove access inherited through other roles or parent resources. Inspect effective access.
Official sources · Snowflake 1
# permissions-revokeSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Prepare tbi_lab and the required create/read permissions.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
SHOW TABLES IN SCHEMA tbi_lab;Returns metadata for accessible tables and columns.
DESCRIBE TABLE tbi_lab.orders;Official sources · Snowflake 1 · Snowflake 2
# inspect-objectsSnowflake · SQL for the selected product. This page does not execute it. Checked against official documentation; not executed in a cloud account.
Snowflake assumes a selected database; BigQuery assumes a selected project. tbi_lab is a practice schema or dataset.
Use an authorized practice environment. Check names, destinations and recipients. Cloud execution and storage may incur charges.
EXECUTE IMMEDIATE $$
DECLARE n INTEGER DEFAULT 2;
BEGIN
RETURN n + 1;
END;
$$;Changes a variable from 2 to 3 and returns 3.
Compare the expected change with the result, access settings or destination in your environment.
BEGIN…END is a procedural block, distinct from BEGIN TRANSACTION.
Official sources · Snowflake 1 · Snowflake 2
# scriptWhen one customer has three orders, that customer appears three times in the joined result. Change the order count and SQL to inspect the matching rows.
Run one read-only statement starting with SELECT or WITH. Tables: customers and orders. Up to 200 rows are shown.
Choose an example or edit the SQL, then run it.
First, FROM reads the customers table, and AS c gives customers the short name c within this query.
Next, INNER JOIN combines it with the orders table. AS o names orders as o. ON c.id = o.customer_id keeps only pairs where the customer identifier c.id equals the order’s customer identifier o.customer_id. Several orders for one customer produce several rows.
SELECT returns the customer identifier c.id, the name c.name and the order identifier o.id. AS order_id names the output column for o.id as order_id.
Finally, ORDER BY c.id, o.id sorts by increasing customer identifier, then by increasing order identifier within each customer.
The dot . in c.id connects a table alias and column name; the comma , separates columns or expressions; the semicolon ; ends the SQL statement.
This runner uses SQLite, independently of the Snowflake / BigQuery selector above. It uses fictional data and runs SQL in your browser. Input is not saved or sent. The engine loads from an external CDN on the first run.
Compare JOIN types · Official SQLite SELECT and JOIN reference