From 988ccfa3217251be94b1fec731b3fe79274ec2ce Mon Sep 17 00:00:00 2001 From: Jordan Hays Date: Thu, 13 Jan 2022 14:07:50 -0800 Subject: [PATCH] add ledger table samples --- .../Table/Create Append-Only Ledger Table.sql | 44 +++++++++++++++ .../Table/Create Updatable Ledger Table.sql | 52 ++++++++++++++++++ .../Table/Create Append-Only Ledger Table.sql | 46 ++++++++++++++++ .../Table/Create Updatable Ledger Table.sql | 54 +++++++++++++++++++ 4 files changed, 196 insertions(+) create mode 100644 samples/features/ssms-templates/Sql/SQL Azure Database/Table/Create Append-Only Ledger Table.sql create mode 100644 samples/features/ssms-templates/Sql/SQL Azure Database/Table/Create Updatable Ledger Table.sql create mode 100644 samples/features/ssms-templates/Sql/Table/Create Append-Only Ledger Table.sql create mode 100644 samples/features/ssms-templates/Sql/Table/Create Updatable Ledger Table.sql diff --git a/samples/features/ssms-templates/Sql/SQL Azure Database/Table/Create Append-Only Ledger Table.sql b/samples/features/ssms-templates/Sql/SQL Azure Database/Table/Create Append-Only Ledger Table.sql new file mode 100644 index 00000000..f35bd318 --- /dev/null +++ b/samples/features/ssms-templates/Sql/SQL Azure Database/Table/Create Append-Only Ledger Table.sql @@ -0,0 +1,44 @@ +-- ============================== +-- Create Append-Only Ledger Table Template +-- Use the Specify Values for Template Parameters command (Ctrl-Shift-M) to fill in the parameter values below. +-- +-- For more details on ledger tables please refer to MSDN documentation: +-- https://docs.microsoft.com/azure/azure-sql/database/ledger-overview +-- +-- To learn more how to use append-only ledger tables in your applications: +-- https://docs.microsoft.com/azure/azure-sql/database/ledger-append-only-ledger-tables +-- ============================== + +IF OBJECT_ID('.', 'U') IS NOT NULL + DROP TABLE . +GO + +--Create append-only ledger table. +CREATE TABLE [].[] +( + --The table must contain at least one user-defined column. + , + + --Ledger tables require GENERATED ALWAYS columns, which can be explicitly defined or auto-generated during table creation + BIGINT GENERATED ALWAYS AS TRANSACTION_ID START, + BIGINT GENERATED ALWAYS AS SEQUENCE_NUMBER START +) +WITH +( + --Set LEDGER = ON + LEDGER = ON + ( + APPEND_ONLY = ON, + --Option to specify the name of the ledger view. If not supplied, the view will be created with the + --default name format: [].[_Ledger] + LEDGER_VIEW = [].[] + ( + --Options to specify ledger view default column names + TRANSACTION_ID_COLUMN_NAME = , + SEQUENCE_NUMBER_COLUMN_NAME = , + OPERATION_TYPE_COLUMN_NAME = , + OPERATION_TYPE_DESC_COLUMN_NAME = + ) + ) +) + diff --git a/samples/features/ssms-templates/Sql/SQL Azure Database/Table/Create Updatable Ledger Table.sql b/samples/features/ssms-templates/Sql/SQL Azure Database/Table/Create Updatable Ledger Table.sql new file mode 100644 index 00000000..d5be9622 --- /dev/null +++ b/samples/features/ssms-templates/Sql/SQL Azure Database/Table/Create Updatable Ledger Table.sql @@ -0,0 +1,52 @@ +-- ============================== +-- Create Updatable Ledger Table Template +-- Use the Specify Values for Template Parameters command (Ctrl-Shift-M) to fill in the parameter values below. +-- +-- For more details on ledger tables please refer to MSDN documentation: +-- https://docs.microsoft.com/azure/azure-sql/database/ledger-overview +-- +-- To learn more how to use updatable ledger tables in your applications: +-- https://docs.microsoft.com/azure/azure-sql/database/ledger-updatable-ledger-tables +-- ============================== + +IF OBJECT_ID('.', 'U') IS NOT NULL + DROP TABLE . +GO + +--Create updatable ledger table. +CREATE TABLE [].[] +( + --The table must contain at least one user-defined column. + , + + --Ledger tables require GENERATED ALWAYS columns, which can be explicitly defined or auto-generated during table creation + BIGINT GENERATED ALWAYS AS TRANSACTION_ID START, + BIGINT GENERATED ALWAYS AS TRANSACTION_ID END, + BIGINT GENERATED ALWAYS AS SEQUENCE_NUMBER START, + BIGINT GENERATED ALWAYS AS SEQUENCE_NUMBER END +) +WITH +( + --Set SYSTEM_VERSIONING to ON + SYSTEM_VERSIONING = ON + ( + --Option to specify the name of the ledger history table. If not supplied, the history table will be created with the + --default name format: [].[MSSQL_LedgerHistoryFor_] + HISTORY_TABLE = [].[] + ), + --Set LEDGER = ON. This is optional if this is a ledger database + LEDGER = ON + ( + --Option to specify the name of the ledger view. If not supplied, the view will be created with the + --default name format: [].[_Ledger] + LEDGER_VIEW = [].[] + ( + --Options to specify ledger view default column names + TRANSACTION_ID_COLUMN_NAME = , + SEQUENCE_NUMBER_COLUMN_NAME = , + OPERATION_TYPE_COLUMN_NAME = , + OPERATION_TYPE_DESC_COLUMN_NAME = + ) + ) +) + diff --git a/samples/features/ssms-templates/Sql/Table/Create Append-Only Ledger Table.sql b/samples/features/ssms-templates/Sql/Table/Create Append-Only Ledger Table.sql new file mode 100644 index 00000000..3979b938 --- /dev/null +++ b/samples/features/ssms-templates/Sql/Table/Create Append-Only Ledger Table.sql @@ -0,0 +1,46 @@ +-- ============================== +-- Create Append-Only Ledger Table Template +-- Use the Specify Values for Template Parameters command (Ctrl-Shift-M) to fill in the parameter values below. +-- +-- For more details on ledger tables please refer to MSDN documentation: +-- https://docs.microsoft.com/azure/azure-sql/database/ledger-overview +-- +-- To learn more how to use append-only ledger tables in your applications: +-- https://docs.microsoft.com/azure/azure-sql/database/ledger-append-only-ledger-tables +-- ============================== +USE +GO + +IF OBJECT_ID('.', 'U') IS NOT NULL + DROP TABLE . +GO + +--Create append-only ledger table. +CREATE TABLE [].[] +( + --The table must contain at least one user-defined column. + , + + --Ledger tables require GENERATED ALWAYS columns, which can be explicitly defined or auto-generated during table creation + BIGINT GENERATED ALWAYS AS TRANSACTION_ID START, + BIGINT GENERATED ALWAYS AS SEQUENCE_NUMBER START +) +WITH +( + --Set LEDGER = ON + LEDGER = ON + ( + APPEND_ONLY = ON, + --Option to specify the name of the ledger view. If not supplied, the view will be created with the + --default name format: [].[_Ledger] + LEDGER_VIEW = [].[] + ( + --Options to specify ledger view default column names + TRANSACTION_ID_COLUMN_NAME = , + SEQUENCE_NUMBER_COLUMN_NAME = , + OPERATION_TYPE_COLUMN_NAME = , + OPERATION_TYPE_DESC_COLUMN_NAME = + ) + ) +) + diff --git a/samples/features/ssms-templates/Sql/Table/Create Updatable Ledger Table.sql b/samples/features/ssms-templates/Sql/Table/Create Updatable Ledger Table.sql new file mode 100644 index 00000000..6410e9b9 --- /dev/null +++ b/samples/features/ssms-templates/Sql/Table/Create Updatable Ledger Table.sql @@ -0,0 +1,54 @@ +-- ============================== +-- Create Updatable Ledger Table Template +-- Use the Specify Values for Template Parameters command (Ctrl-Shift-M) to fill in the parameter values below. +-- +-- For more details on ledger tables please refer to MSDN documentation: +-- https://docs.microsoft.com/azure/azure-sql/database/ledger-overview +-- +-- To learn more how to use updatable ledger tables in your applications: +-- https://docs.microsoft.com/azure/azure-sql/database/ledger-updatable-ledger-tables +-- ============================== +USE +GO + +IF OBJECT_ID('.', 'U') IS NOT NULL + DROP TABLE . +GO + +--Create updatable ledger table. +CREATE TABLE [].[] +( + --The table must contain at least one user-defined column. + , + + --Ledger tables require GENERATED ALWAYS columns, which can be explicitly defined or auto-generated during table creation + BIGINT GENERATED ALWAYS AS TRANSACTION_ID START, + BIGINT GENERATED ALWAYS AS TRANSACTION_ID END, + BIGINT GENERATED ALWAYS AS SEQUENCE_NUMBER START, + BIGINT GENERATED ALWAYS AS SEQUENCE_NUMBER END +) +WITH +( + --Set SYSTEM_VERSIONING to ON + SYSTEM_VERSIONING = ON + ( + --Option to specify the name of the ledger history table. If not supplied, the history table will be created with the + --default name format: [].[MSSQL_LedgerHistoryFor_] + HISTORY_TABLE = [].[] + ), + --Set LEDGER = ON. This is optional if this is a ledger database + LEDGER = ON + ( + --Option to specify the name of the ledger view. If not supplied, the view will be created with the + --default name format: [].[_Ledger] + LEDGER_VIEW = [].[] + ( + --Options to specify ledger view default column names + TRANSACTION_ID_COLUMN_NAME = , + SEQUENCE_NUMBER_COLUMN_NAME = , + OPERATION_TYPE_COLUMN_NAME = , + OPERATION_TYPE_DESC_COLUMN_NAME = + ) + ) +) +