Datasets:

Modalities:
Tabular
Text
Formats:
parquet
ArXiv:
Libraries:
Datasets
Dask
License:
id
int64
0
540
file_name
stringlengths
4
38
file_path
stringlengths
16
123
content
stringlengths
126
1.72M
size
int64
126
1.8M
language
stringclasses
1 value
extension
stringclasses
1 value
total_lines
int64
4
74.3k
avg_line_length
float64
6.01
89.8
max_line_length
int64
33
3.68k
alphanum_fraction
float64
0.33
0.95
repo_name
stringclasses
95 values
repo_stars
int64
0
50
repo_forks
int64
0
14
repo_open_issues
int64
0
34
repo_license
stringclasses
7 values
repo_extraction_date
stringclasses
11 values
near_duplicates_stackv2
bool
2 classes
near_duplicates_stackv1
bool
2 classes
exact_duplicates_stackv1
bool
2 classes
exact_duplicates_stackv2
bool
2 classes
0
TSqlParserCore.g4
christianhelle_sqlcequery/Source/TSqlParser/TSqlParserCore.g4
/* T-SQL (Transact-SQL, MSSQL) grammar. The MIT License (MIT). Copyright (c) 2017, Mark Adams ([email protected]) Copyright (c) 2015-2017, Ivan Kochurkin ([email protected]), Positive Technologies. Copyright (c) 2016, Scott Ure ([email protected]). Copyright (c) 2016, Rui Zhang ([email protected]). Copyright (c) 2016, Marcus Henriksson ([email protected]). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ parser grammar TSqlParserCore; options { tokenVocab=TSqlLexerCore; } tsql_file : batch* EOF | execute_body_batch go_batch_statement* EOF ; batch : go_batch_statement | execute_body_batch? (go_batch_statement | sql_clauses+) go_statement* | batch_level_statement go_statement* | go_statement ; batch_level_statement : create_or_alter_function | create_or_alter_procedure | create_or_alter_trigger | create_view ; sql_clauses : dml_clause SEMI? | cfl_statement SEMI? | another_statement SEMI? | ddl_clause SEMI? | dbcc_special SEMI? | dbcc_clause SEMI? | backup_statement SEMI? | SEMI ; // Data Manipulation Language: https://msdn.microsoft.com/en-us/library/ff848766(v=sql.120).aspx dml_clause : merge_statement | delete_statement | insert_statement | select_statement_standalone | update_statement ; // Data Definition Language: https://msdn.microsoft.com/en-us/library/ff848799.aspx) ddl_clause : alter_application_role | alter_assembly | alter_asymmetric_key | alter_authorization | alter_authorization_for_azure_dw | alter_authorization_for_parallel_dw | alter_authorization_for_sql_database | alter_availability_group | alter_certificate | alter_column_encryption_key | alter_credential | alter_cryptographic_provider | alter_database | alter_db_role | alter_endpoint | create_or_alter_event_session | alter_external_data_source | alter_external_library | alter_external_resource_pool | alter_fulltext_catalog | alter_fulltext_stoplist | alter_login_azure_sql | alter_login_azure_sql_dw_and_pdw | alter_login_sql_server | alter_master_key_azure_sql | alter_master_key_sql_server | alter_message_type | alter_partition_function | alter_partition_scheme | alter_remote_service_binding | alter_resource_governor | alter_schema_azure_sql_dw_and_pdw | alter_schema_sql | alter_sequence | alter_server_audit | alter_server_audit_specification | alter_server_configuration | alter_server_role | alter_server_role_pdw | alter_service | alter_service_master_key | alter_symmetric_key | alter_table | alter_user | alter_user_azure_sql | alter_workload_group | create_application_role | create_assembly | create_asymmetric_key | create_column_encryption_key | create_column_master_key | create_credential | create_cryptographic_provider | create_database | create_db_role | create_event_notification | create_external_library | create_external_resource_pool | create_fulltext_catalog | create_fulltext_stoplist | create_index | create_login_azure_sql | create_login_pdw | create_login_sql_server | create_master_key_azure_sql | create_master_key_sql_server | create_or_alter_broker_priority | create_remote_service_binding | create_resource_pool | create_route | create_rule | create_schema | create_schema_azure_sql_dw_and_pdw | create_search_property_list | create_security_policy | create_sequence | create_server_audit | create_server_audit_specification | create_server_role | create_service | create_statistics | create_symmetric_key | create_synonym | create_table | create_type | create_user | create_user_azure_sql_dw | create_workload_group | create_xml_index | create_xml_schema_collection | drop_aggregate | drop_application_role | drop_assembly | drop_asymmetric_key | drop_availability_group | drop_broker_priority | drop_certificate | drop_column_encryption_key | drop_column_master_key | drop_contract | drop_credential | drop_cryptograhic_provider | drop_database | drop_database_audit_specification | drop_database_encryption_key | drop_database_scoped_credential | drop_db_role | drop_default | drop_endpoint | drop_event_notifications | drop_event_session | drop_external_data_source | drop_external_file_format | drop_external_library | drop_external_resource_pool | drop_external_table | drop_fulltext_catalog | drop_fulltext_index | drop_fulltext_stoplist | drop_function | drop_index | drop_login | drop_master_key | drop_message_type | drop_partition_function | drop_partition_scheme | drop_procedure | drop_queue | drop_remote_service_binding | drop_resource_pool | drop_route | drop_rule | drop_schema | drop_search_property_list | drop_security_policy | drop_sequence | drop_server_audit | drop_server_audit_specification | drop_server_role | drop_service | drop_signature | drop_statistics | drop_statistics_name_azure_dw_and_pdw | drop_symmetric_key | drop_synonym | drop_table | drop_trigger | drop_type | drop_user | drop_view | drop_workload_group | drop_xml_schema_collection | disable_trigger | enable_trigger | lock_table | truncate_table | update_statistics ; backup_statement : backup_database | backup_log | backup_certificate | backup_master_key | backup_service_master_key ; // Control-of-Flow Language: https://docs.microsoft.com/en-us/sql/t-sql/language-elements/control-of-flow cfl_statement : block_statement | break_statement | continue_statement | goto_statement | if_statement | return_statement | throw_statement | try_catch_statement | waitfor_statement | while_statement | print_statement | raiseerror_statement ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/begin-end-transact-sql block_statement : BEGIN ';'? sql_clauses* END ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/break-transact-sql break_statement : BREAK ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/continue-transact-sql continue_statement : CONTINUE ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/goto-transact-sql goto_statement : GOTO id ';'? | id ':' ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/return-transact-sql return_statement : RETURN expression? ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/if-else-transact-sql if_statement : IF search_condition sql_clauses (ELSE sql_clauses)? ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/throw-transact-sql throw_statement : THROW (throw_error_number ',' throw_message ',' throw_state)? ';'? ; throw_error_number : DECIMAL | LOCAL_ID ; throw_message : STRING | LOCAL_ID ; throw_state : DECIMAL | LOCAL_ID ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/try-catch-transact-sql try_catch_statement : BEGIN TRY ';'? try_clauses=sql_clauses+ END TRY ';'? BEGIN CATCH ';'? catch_clauses=sql_clauses* END CATCH ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/waitfor-transact-sql waitfor_statement : WAITFOR receive_statement? ','? ((DELAY | TIME | TIMEOUT) time)? expression? ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/while-transact-sql while_statement : WHILE search_condition (sql_clauses | BREAK ';'? | CONTINUE ';'?) ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/print-transact-sql print_statement : PRINT (expression | DOUBLE_QUOTE_ID) (',' LOCAL_ID)* ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/raiserror-transact-sql raiseerror_statement : RAISERROR '(' msg=(DECIMAL | STRING | LOCAL_ID) ',' severity=constant_LOCAL_ID ',' state=constant_LOCAL_ID (',' constant_LOCAL_ID)* ')' (WITH (LOG | SETERROR | NOWAIT))? ';'? | RAISERROR DECIMAL formatstring=(STRING | LOCAL_ID | DOUBLE_QUOTE_ID) (',' argument=(DECIMAL | STRING | LOCAL_ID))* ; empty_statement : ';' ; another_statement : declare_statement | execute_statement | cursor_statement | conversation_statement | create_contract | create_queue | alter_queue | kill_statement | message_statement | security_statement | set_statement | transaction_statement | use_statement | setuser_statement | reconfigure_statement | shutdown_statement ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-application-role-transact-sql alter_application_role : ALTER APPLICATION ROLE appliction_role=id WITH (COMMA? NAME EQUAL new_application_role_name=id)? (COMMA? PASSWORD EQUAL application_role_password=STRING)? (COMMA? DEFAULT_SCHEMA EQUAL app_role_default_schema=id)? ; create_application_role : CREATE APPLICATION ROLE appliction_role=id WITH (COMMA? PASSWORD EQUAL application_role_password=STRING)? (COMMA? DEFAULT_SCHEMA EQUAL app_role_default_schema=id)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-aggregate-transact-sql drop_aggregate : DROP AGGREGATE ( IF EXISTS )? ( schema_name=id DOT )? aggregate_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-application-role-transact-sql drop_application_role : DROP APPLICATION ROLE rolename=id ; alter_assembly : alter_assembly_start assembly_name=id alter_assembly_clause ; alter_assembly_start : ALTER ASSEMBLY ; alter_assembly_clause : alter_assembly_from_clause? alter_assembly_with_clause? alter_assembly_drop_clause? alter_assembly_add_clause? ; alter_assembly_from_clause : alter_assembly_from_clause_start (client_assembly_specifier | alter_assembly_file_bits ) ; alter_assembly_from_clause_start : FROM ; alter_assembly_drop_clause : alter_assembly_drop alter_assembly_drop_multiple_files ; alter_assembly_drop_multiple_files : ALL | multiple_local_files ; alter_assembly_drop : DROP ; alter_assembly_add_clause : alter_asssembly_add_clause_start alter_assembly_client_file_clause ; alter_asssembly_add_clause_start : ADD FILE FROM ; // need to implement alter_assembly_client_file_clause : alter_assembly_file_name (alter_assembly_as id)? ; alter_assembly_file_name : STRING ; //need to implement alter_assembly_file_bits : alter_assembly_as id ; alter_assembly_as : AS ; alter_assembly_with_clause : alter_assembly_with assembly_option ; alter_assembly_with : WITH ; client_assembly_specifier : network_file_share | local_file | STRING ; assembly_option : PERMISSION_SET EQUAL (SAFE|EXTERNAL_ACCESS|UNSAFE) | VISIBILITY EQUAL (ON | OFF) | UNCHECKED DATA | assembly_option COMMA ; network_file_share : network_file_start network_computer file_path ; network_computer : computer_name=id ; network_file_start : DOUBLE_BACK_SLASH ; file_path : file_directory_path_separator file_path | id ; file_directory_path_separator : '\\' ; local_file : local_drive file_path ; local_drive : DISK_DRIVE ; multiple_local_files : multiple_local_file_start local_file SINGLE_QUOTE COMMA | local_file ; multiple_local_file_start : SINGLE_QUOTE ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-assembly-transact-sql create_assembly : CREATE ASSEMBLY assembly_name=id (AUTHORIZATION owner_name=id)? FROM (COMMA? (STRING|BINARY) )+ (WITH PERMISSION_SET EQUAL (SAFE|EXTERNAL_ACCESS|UNSAFE) )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-assembly-transact-sql drop_assembly : DROP ASSEMBLY ( IF EXISTS )? (COMMA? assembly_name=id)+ ( WITH NO DEPENDENTS )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-asymmetric-key-transact-sql alter_asymmetric_key : alter_asymmetric_key_start Asym_Key_Name=id (asymmetric_key_option | REMOVE PRIVATE KEY ) ; alter_asymmetric_key_start : ALTER ASYMMETRIC KEY ; asymmetric_key_option : asymmetric_key_option_start asymmetric_key_password_change_option ( COMMA asymmetric_key_password_change_option)? RR_BRACKET ; asymmetric_key_option_start : WITH PRIVATE KEY LR_BRACKET ; asymmetric_key_password_change_option : DECRYPTION BY PASSWORD EQUAL STRING | ENCRYPTION BY PASSWORD EQUAL STRING ; //https://docs.microsoft.com/en-us/sql/t-sql/statements/create-asymmetric-key-transact-sql create_asymmetric_key : CREATE ASYMMETRIC KEY Asym_Key_Nam=id (AUTHORIZATION database_principal_name=id)? ( FROM (FILE EQUAL STRING |EXECUTABLE_FILE EQUAL STRING|ASSEMBLY Assembly_Name=id | PROVIDER Provider_Name=id) )? (WITH (ALGORITHM EQUAL ( RSA_4096 | RSA_3072 | RSA_2048 | RSA_1024 | RSA_512) |PROVIDER_KEY_NAME EQUAL provider_key_name=STRING | CREATION_DISPOSITION EQUAL (CREATE_NEW|OPEN_EXISTING) ) )? (ENCRYPTION BY PASSWORD EQUAL asymmetric_key_password=STRING )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-asymmetric-key-transact-sql drop_asymmetric_key : DROP ASYMMETRIC KEY key_name=id ( REMOVE PROVIDER KEY )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-authorization-transact-sql alter_authorization : alter_authorization_start (class_type colon_colon)? entity=entity_name entity_to authorization_grantee ; authorization_grantee : principal_name=id | SCHEMA OWNER ; entity_to : TO ; colon_colon : COLON COLON ; alter_authorization_start : ALTER AUTHORIZATION ON ; alter_authorization_for_sql_database : alter_authorization_start (class_type_for_sql_database colon_colon)? entity=entity_name entity_to authorization_grantee ; alter_authorization_for_azure_dw : alter_authorization_start (class_type_for_azure_dw colon_colon)? entity=entity_name_for_azure_dw entity_to authorization_grantee ; alter_authorization_for_parallel_dw : alter_authorization_start (class_type_for_parallel_dw colon_colon)? entity=entity_name_for_parallel_dw entity_to authorization_grantee ; class_type : OBJECT | ASSEMBLY | ASYMMETRIC KEY | AVAILABILITY GROUP | CERTIFICATE | CONTRACT | TYPE | DATABASE | ENDPOINT | FULLTEXT CATALOG | FULLTEXT STOPLIST | MESSAGE TYPE | REMOTE SERVICE BINDING | ROLE | ROUTE | SCHEMA | SEARCH PROPERTY LIST | SERVER ROLE | SERVICE | SYMMETRIC KEY | XML SCHEMA COLLECTION ; class_type_for_sql_database : OBJECT | ASSEMBLY | ASYMMETRIC KEY | CERTIFICATE | TYPE | DATABASE | FULLTEXT CATALOG | FULLTEXT STOPLIST | ROLE | SCHEMA | SEARCH PROPERTY LIST | SYMMETRIC KEY | XML SCHEMA COLLECTION ; class_type_for_azure_dw : SCHEMA | OBJECT ; class_type_for_parallel_dw : DATABASE | SCHEMA | OBJECT ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-availability-group-transact-sql drop_availability_group : DROP AVAILABILITY GROUP group_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-availability-group-transact-sql alter_availability_group : alter_availability_group_start alter_availability_group_options ; alter_availability_group_start : ALTER AVAILABILITY GROUP group_name=id ; alter_availability_group_options : SET LR_BRACKET ( ( AUTOMATED_BACKUP_PREFERENCE EQUAL ( PRIMARY | SECONDARY_ONLY| SECONDARY | NONE ) | FAILURE_CONDITION_LEVEL EQUAL DECIMAL | HEALTH_CHECK_TIMEOUT EQUAL milliseconds=DECIMAL | DB_FAILOVER EQUAL ( ON | OFF ) | REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT EQUAL DECIMAL ) RR_BRACKET ) | ADD DATABASE database_name=id | REMOVE DATABASE database_name=id | ADD REPLICA ON server_instance=STRING (WITH LR_BRACKET ( (ENDPOINT_URL EQUAL STRING)? (COMMA? AVAILABILITY_MODE EQUAL (SYNCHRONOUS_COMMIT| ASYNCHRONOUS_COMMIT))? (COMMA? FAILOVER_MODE EQUAL (AUTOMATIC|MANUAL) )? (COMMA? SEEDING_MODE EQUAL (AUTOMATIC|MANUAL) )? (COMMA? BACKUP_PRIORITY EQUAL DECIMAL)? ( COMMA? PRIMARY_ROLE LR_BRACKET ALLOW_CONNECTIONS EQUAL ( READ_WRITE | ALL ) RR_BRACKET)? ( COMMA? SECONDARY_ROLE LR_BRACKET ALLOW_CONNECTIONS EQUAL ( READ_ONLY ) RR_BRACKET )? ) ) RR_BRACKET |SECONDARY_ROLE LR_BRACKET (ALLOW_CONNECTIONS EQUAL (NO|READ_ONLY|ALL) | READ_ONLY_ROUTING_LIST EQUAL ( LR_BRACKET ( ( STRING) ) RR_BRACKET ) ) |PRIMARY_ROLE LR_BRACKET (ALLOW_CONNECTIONS EQUAL (NO|READ_ONLY|ALL) | READ_ONLY_ROUTING_LIST EQUAL ( LR_BRACKET ( (COMMA? STRING)*|NONE ) RR_BRACKET ) | SESSION_TIMEOUT EQUAL session_timeout=DECIMAL ) | MODIFY REPLICA ON server_instance=STRING (WITH LR_BRACKET (ENDPOINT_URL EQUAL STRING| AVAILABILITY_MODE EQUAL (SYNCHRONOUS_COMMIT| ASYNCHRONOUS_COMMIT) | FAILOVER_MODE EQUAL (AUTOMATIC|MANUAL) | SEEDING_MODE EQUAL (AUTOMATIC|MANUAL) | BACKUP_PRIORITY EQUAL DECIMAL ) |SECONDARY_ROLE LR_BRACKET (ALLOW_CONNECTIONS EQUAL (NO|READ_ONLY|ALL) | READ_ONLY_ROUTING_LIST EQUAL ( LR_BRACKET ( ( STRING) ) RR_BRACKET ) ) |PRIMARY_ROLE LR_BRACKET (ALLOW_CONNECTIONS EQUAL (NO|READ_ONLY|ALL) | READ_ONLY_ROUTING_LIST EQUAL ( LR_BRACKET ( (COMMA? STRING)*|NONE ) RR_BRACKET ) | SESSION_TIMEOUT EQUAL session_timeout=DECIMAL ) ) RR_BRACKET | REMOVE REPLICA ON STRING | JOIN | JOIN AVAILABILITY GROUP ON (COMMA? ag_name=STRING WITH LR_BRACKET ( LISTENER_URL EQUAL STRING COMMA AVAILABILITY_MODE EQUAL (SYNCHRONOUS_COMMIT|ASYNCHRONOUS_COMMIT) COMMA FAILOVER_MODE EQUAL MANUAL COMMA SEEDING_MODE EQUAL (AUTOMATIC|MANUAL) RR_BRACKET ) )+ | MODIFY AVAILABILITY GROUP ON (COMMA? ag_name_modified=STRING WITH LR_BRACKET (LISTENER_URL EQUAL STRING (COMMA? AVAILABILITY_MODE EQUAL (SYNCHRONOUS_COMMIT|ASYNCHRONOUS_COMMIT) )? (COMMA? FAILOVER_MODE EQUAL MANUAL )? (COMMA? SEEDING_MODE EQUAL (AUTOMATIC|MANUAL))? RR_BRACKET ) )+ |GRANT CREATE ANY DATABASE | DENY CREATE ANY DATABASE | FAILOVER | FORCE_FAILOVER_ALLOW_DATA_LOSS | ADD LISTENER listener_name=STRING LR_BRACKET ( WITH DHCP (ON LR_BRACKET ip_v4_failover ip_v4_failover RR_BRACKET ) | WITH IP LR_BRACKET ( (COMMA? LR_BRACKET ( ip_v4_failover COMMA ip_v4_failover | ip_v6_failover ) RR_BRACKET)+ RR_BRACKET (COMMA PORT EQUAL DECIMAL)? ) ) RR_BRACKET | MODIFY LISTENER (ADD IP LR_BRACKET (ip_v4_failover ip_v4_failover | ip_v6_failover) RR_BRACKET | PORT EQUAL DECIMAL ) |RESTART LISTENER STRING |REMOVE LISTENER STRING |OFFLINE | WITH LR_BRACKET DTC_SUPPORT EQUAL PER_DB RR_BRACKET ; ip_v4_failover : STRING ; ip_v6_failover : STRING ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-broker-priority-transact-sql // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-broker-priority-transact-sql create_or_alter_broker_priority : (CREATE | ALTER) BROKER PRIORITY ConversationPriorityName=id FOR CONVERSATION SET LR_BRACKET ( CONTRACT_NAME EQUAL ( ( id) | ANY ) COMMA? )? ( LOCAL_SERVICE_NAME EQUAL (DOUBLE_FORWARD_SLASH? id | ANY ) COMMA? )? ( REMOTE_SERVICE_NAME EQUAL (RemoteServiceName=STRING | ANY ) COMMA? )? ( PRIORITY_LEVEL EQUAL ( PriorityValue=DECIMAL | DEFAULT ) ) ? RR_BRACKET ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-broker-priority-transact-sql drop_broker_priority : DROP BROKER PRIORITY ConversationPriorityName=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-certificate-transact-sql alter_certificate : ALTER CERTIFICATE certificate_name=id (REMOVE PRIVATE_KEY | WITH PRIVATE KEY LR_BRACKET ( FILE EQUAL STRING COMMA? | DECRYPTION BY PASSWORD EQUAL STRING COMMA?| ENCRYPTION BY PASSWORD EQUAL STRING COMMA?)+ RR_BRACKET | WITH ACTIVE FOR BEGIN_DIALOG EQUAL ( ON | OFF ) ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-column-encryption-key-transact-sql alter_column_encryption_key : ALTER COLUMN ENCRYPTION KEY column_encryption_key=id (ADD | DROP) VALUE LR_BRACKET COLUMN_MASTER_KEY EQUAL column_master_key_name=id ( COMMA ALGORITHM EQUAL algorithm_name=STRING COMMA ENCRYPTED_VALUE EQUAL BINARY)? RR_BRACKET ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-column-encryption-key-transact-sql create_column_encryption_key : CREATE COLUMN ENCRYPTION KEY column_encryption_key=id WITH VALUES (LR_BRACKET COMMA? COLUMN_MASTER_KEY EQUAL column_master_key_name=id COMMA ALGORITHM EQUAL algorithm_name=STRING COMMA ENCRYPTED_VALUE EQUAL encrypted_value=BINARY RR_BRACKET COMMA?)+ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-certificate-transact-sql drop_certificate : DROP CERTIFICATE certificate_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-column-encryption-key-transact-sql drop_column_encryption_key : DROP COLUMN ENCRYPTION KEY key_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-column-master-key-transact-sql drop_column_master_key : DROP COLUMN MASTER KEY key_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-contract-transact-sql drop_contract : DROP CONTRACT dropped_contract_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-credential-transact-sql drop_credential : DROP CREDENTIAL credential_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-cryptographic-provider-transact-sql drop_cryptograhic_provider : DROP CRYPTOGRAPHIC PROVIDER provider_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-database-transact-sql drop_database : DROP DATABASE ( IF EXISTS )? (COMMA? database_name_or_database_snapshot_name=id)+ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-database-audit-specification-transact-sql drop_database_audit_specification : DROP DATABASE AUDIT SPECIFICATION audit_specification_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-database-encryption-key-transact-sql?view=sql-server-ver15 drop_database_encryption_key : DROP DATABASE ENCRYPTION KEY ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-database-scoped-credential-transact-sql drop_database_scoped_credential : DROP DATABASE SCOPED CREDENTIAL credential_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-default-transact-sql drop_default : DROP DEFAULT ( IF EXISTS )? (COMMA? (schema_name=id DOT)? default_name=id) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-endpoint-transact-sql drop_endpoint : DROP ENDPOINT endPointName=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-external-data-source-transact-sql drop_external_data_source : DROP EXTERNAL DATA SOURCE external_data_source_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-external-file-format-transact-sql drop_external_file_format : DROP EXTERNAL FILE FORMAT external_file_format_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-external-library-transact-sql drop_external_library : DROP EXTERNAL LIBRARY library_name=id ( AUTHORIZATION owner_name=id )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-external-resource-pool-transact-sql drop_external_resource_pool : DROP EXTERNAL RESOURCE POOL pool_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-external-table-transact-sql drop_external_table : DROP EXTERNAL TABLE (database_name=id DOT)? (schema_name=id DOT)? table=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-event-notification-transact-sql drop_event_notifications : DROP EVENT NOTIFICATION (COMMA? notification_name=id)+ ON (SERVER|DATABASE|QUEUE queue_name=id) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-event-session-transact-sql drop_event_session : DROP EVENT SESSION event_session_name=id ON SERVER ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-fulltext-catalog-transact-sql drop_fulltext_catalog : DROP FULLTEXT CATALOG catalog_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-fulltext-index-transact-sql drop_fulltext_index : DROP FULLTEXT INDEX ON (schema=id DOT)? table=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-fulltext-stoplist-transact-sql drop_fulltext_stoplist : DROP FULLTEXT STOPLIST stoplist_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-login-transact-sql drop_login : DROP LOGIN login_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-master-key-transact-sql drop_master_key : DROP MASTER KEY ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-message-type-transact-sql drop_message_type : DROP MESSAGE TYPE message_type_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-partition-function-transact-sql drop_partition_function : DROP PARTITION FUNCTION partition_function_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-partition-scheme-transact-sql drop_partition_scheme : DROP PARTITION SCHEME partition_scheme_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-queue-transact-sql drop_queue : DROP QUEUE (database_name=id DOT)? (schema_name=id DOT)? queue_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-remote-service-binding-transact-sql drop_remote_service_binding : DROP REMOTE SERVICE BINDING binding_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-resource-pool-transact-sql drop_resource_pool : DROP RESOURCE POOL pool_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-role-transact-sql drop_db_role : DROP ROLE ( IF EXISTS )? role_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-route-transact-sql drop_route : DROP ROUTE route_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-rule-transact-sql drop_rule : DROP RULE ( IF EXISTS )? (COMMA? (schema_name=id DOT)? rule_name=id)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-schema-transact-sql drop_schema : DROP SCHEMA ( IF EXISTS )? schema_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-search-property-list-transact-sql drop_search_property_list : DROP SEARCH PROPERTY LIST property_list_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-security-policy-transact-sql drop_security_policy : DROP SECURITY POLICY ( IF EXISTS )? (schema_name=id DOT )? security_policy_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-sequence-transact-sql drop_sequence : DROP SEQUENCE ( IF EXISTS )? ( COMMA? (database_name=id DOT)? (schema_name=id DOT)? sequence_name=id )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-server-audit-transact-sql drop_server_audit : DROP SERVER AUDIT audit_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-server-audit-specification-transact-sql drop_server_audit_specification : DROP SERVER AUDIT SPECIFICATION audit_specification_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-server-role-transact-sql drop_server_role : DROP SERVER ROLE role_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-service-transact-sql drop_service : DROP SERVICE dropped_service_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-signature-transact-sql drop_signature : DROP ( COUNTER )? SIGNATURE FROM (schema_name=id DOT)? module_name=id BY (COMMA? CERTIFICATE cert_name=id | COMMA? ASYMMETRIC KEY Asym_key_name=id )+ ; drop_statistics_name_azure_dw_and_pdw : DROP STATISTICS (schema_name=id DOT)? object_name=id DOT statistics_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-symmetric-key-transact-sql drop_symmetric_key : DROP SYMMETRIC KEY symmetric_key_name=id (REMOVE PROVIDER KEY)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-synonym-transact-sql drop_synonym : DROP SYNONYM ( IF EXISTS )? ( schema=id DOT )? synonym_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-user-transact-sql drop_user : DROP USER ( IF EXISTS )? user_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-workload-group-transact-sql drop_workload_group : DROP WORKLOAD GROUP group_name=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-xml-schema-collection-transact-sql drop_xml_schema_collection : DROP XML SCHEMA COLLECTION ( relational_schema=id DOT )? sql_identifier=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/disable-trigger-transact-sql disable_trigger : DISABLE TRIGGER ( ( COMMA? (schema_name=id DOT)? trigger_name=id )+ | ALL) ON ((schema_id=id DOT)? object_name=id|DATABASE|ALL SERVER) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/enable-trigger-transact-sql enable_trigger : ENABLE TRIGGER ( ( COMMA? (schema_name=id DOT)? trigger_name=id )+ | ALL) ON ( (schema_id=id DOT)? object_name=id|DATABASE|ALL SERVER) ; lock_table : LOCK TABLE table_name IN (SHARE | EXCLUSIVE) MODE (WAIT seconds=DECIMAL | NOWAIT)? ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/truncate-table-transact-sql truncate_table : TRUNCATE TABLE table_name ( WITH LR_BRACKET PARTITIONS LR_BRACKET (COMMA? (DECIMAL|DECIMAL TO DECIMAL) )+ RR_BRACKET RR_BRACKET )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-column-master-key-transact-sql create_column_master_key : CREATE COLUMN MASTER KEY key_name=id WITH LR_BRACKET KEY_STORE_PROVIDER_NAME EQUAL key_store_provider_name=STRING COMMA KEY_PATH EQUAL key_path=STRING RR_BRACKET ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-credential-transact-sql alter_credential : ALTER CREDENTIAL credential_name=id WITH IDENTITY EQUAL identity_name=STRING ( COMMA SECRET EQUAL secret=STRING )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-credential-transact-sql create_credential : CREATE CREDENTIAL credential_name=id WITH IDENTITY EQUAL identity_name=STRING ( COMMA SECRET EQUAL secret=STRING )? ( FOR CRYPTOGRAPHIC PROVIDER cryptographic_provider_name=id )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-cryptographic-provider-transact-sql alter_cryptographic_provider : ALTER CRYPTOGRAPHIC PROVIDER provider_name=id (FROM FILE EQUAL crypto_provider_ddl_file=STRING)? (ENABLE | DISABLE)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-cryptographic-provider-transact-sql create_cryptographic_provider : CREATE CRYPTOGRAPHIC PROVIDER provider_name=id FROM FILE EQUAL path_of_DLL=STRING ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-event-notification-transact-sql create_event_notification : CREATE EVENT NOTIFICATION event_notification_name=id ON (SERVER|DATABASE|QUEUE queue_name=id) (WITH FAN_IN)? FOR (COMMA? event_type_or_group=id)+ TO SERVICE broker_service=STRING COMMA broker_service_specifier_or_current_database=STRING ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-event-session-transact-sql // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-event-session-transact-sql // todo: not implemented create_or_alter_event_session : (CREATE | ALTER) EVENT SESSION event_session_name=id ON SERVER (COMMA? ADD EVENT ( (event_module_guid=id DOT)? event_package_name=id DOT event_name=id) (LR_BRACKET (SET ( COMMA? event_customizable_attributue=id EQUAL (DECIMAL|STRING) )* )? ( ACTION LR_BRACKET (COMMA? (event_module_guid=id DOT)? event_package_name=id DOT action_name=id)+ RR_BRACKET)+ (WHERE event_session_predicate_expression)? RR_BRACKET )* )* (COMMA? DROP EVENT (event_module_guid=id DOT)? event_package_name=id DOT event_name=id )* ( (ADD TARGET (event_module_guid=id DOT)? event_package_name=id DOT target_name=id ) ( LR_BRACKET SET (COMMA? target_parameter_name=id EQUAL (LR_BRACKET? DECIMAL RR_BRACKET? |STRING) )+ RR_BRACKET )* )* (DROP TARGET (event_module_guid=id DOT)? event_package_name=id DOT target_name=id )* (WITH LR_BRACKET (COMMA? MAX_MEMORY EQUAL max_memory=DECIMAL (KB|MB) )? (COMMA? EVENT_RETENTION_MODE EQUAL (ALLOW_SINGLE_EVENT_LOSS | ALLOW_MULTIPLE_EVENT_LOSS | NO_EVENT_LOSS ) )? (COMMA? MAX_DISPATCH_LATENCY EQUAL (max_dispatch_latency_seconds=DECIMAL SECONDS | INFINITE) )? (COMMA? MAX_EVENT_SIZE EQUAL max_event_size=DECIMAL (KB|MB) )? (COMMA? MEMORY_PARTITION_MODE EQUAL (NONE | PER_NODE | PER_CPU) )? (COMMA? TRACK_CAUSALITY EQUAL (ON|OFF) )? (COMMA? STARTUP_STATE EQUAL (ON|OFF) )? RR_BRACKET )? (STATE EQUAL (START|STOP) )? ; event_session_predicate_expression : ( COMMA? (AND|OR)? NOT? ( event_session_predicate_factor | LR_BRACKET event_session_predicate_expression RR_BRACKET) )+ ; event_session_predicate_factor : event_session_predicate_leaf | LR_BRACKET event_session_predicate_expression RR_BRACKET ; event_session_predicate_leaf : (event_field_name=id | (event_field_name=id |( (event_module_guid=id DOT)? event_package_name=id DOT predicate_source_name=id ) ) (EQUAL |(LESS GREATER) | (EXCLAMATION EQUAL) | GREATER | (GREATER EQUAL)| LESS | LESS EQUAL) (DECIMAL | STRING) ) | (event_module_guid=id DOT)? event_package_name=id DOT predicate_compare_name=id LR_BRACKET (event_field_name=id |( (event_module_guid=id DOT)? event_package_name=id DOT predicate_source_name=id ) COMMA (DECIMAL | STRING) ) RR_BRACKET ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-external-data-source-transact-sql alter_external_data_source : ALTER EXTERNAL DATA SOURCE data_source_name=id SET ( LOCATION EQUAL location=STRING COMMA? | RESOURCE_MANAGER_LOCATION EQUAL resource_manager_location=STRING COMMA? | CREDENTIAL EQUAL credential_name=id )+ | ALTER EXTERNAL DATA SOURCE data_source_name=id WITH LR_BRACKET TYPE EQUAL BLOB_STORAGE COMMA LOCATION EQUAL location=STRING (COMMA CREDENTIAL EQUAL credential_name=id )? RR_BRACKET ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-external-library-transact-sql alter_external_library : ALTER EXTERNAL LIBRARY library_name=id (AUTHORIZATION owner_name=id)? (SET|ADD) ( LR_BRACKET CONTENT EQUAL (client_library=STRING | BINARY | NONE) (COMMA PLATFORM EQUAL (WINDOWS|LINUX)? RR_BRACKET) WITH (COMMA? LANGUAGE EQUAL (R|PYTHON) | DATA_SOURCE EQUAL external_data_source_name=id )+ RR_BRACKET ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-external-library-transact-sql create_external_library : CREATE EXTERNAL LIBRARY library_name=id (AUTHORIZATION owner_name=id)? FROM (COMMA? LR_BRACKET? (CONTENT EQUAL)? (client_library=STRING | BINARY | NONE) (COMMA PLATFORM EQUAL (WINDOWS|LINUX)? RR_BRACKET)? ) ( WITH (COMMA? LANGUAGE EQUAL (R|PYTHON) | DATA_SOURCE EQUAL external_data_source_name=id )+ RR_BRACKET )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-external-resource-pool-transact-sql alter_external_resource_pool : ALTER EXTERNAL RESOURCE POOL (pool_name=id | DEFAULT_DOUBLE_QUOTE) WITH LR_BRACKET MAX_CPU_PERCENT EQUAL max_cpu_percent=DECIMAL ( COMMA? AFFINITY CPU EQUAL (AUTO|(COMMA? DECIMAL TO DECIMAL |COMMA DECIMAL )+ ) | NUMANODE EQUAL (COMMA? DECIMAL TO DECIMAL| COMMA? DECIMAL )+ ) (COMMA? MAX_MEMORY_PERCENT EQUAL max_memory_percent=DECIMAL)? (COMMA? MAX_PROCESSES EQUAL max_processes=DECIMAL)? RR_BRACKET ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-external-resource-pool-transact-sql create_external_resource_pool : CREATE EXTERNAL RESOURCE POOL pool_name=id WITH LR_BRACKET MAX_CPU_PERCENT EQUAL max_cpu_percent=DECIMAL ( COMMA? AFFINITY CPU EQUAL (AUTO|(COMMA? DECIMAL TO DECIMAL |COMMA DECIMAL )+ ) | NUMANODE EQUAL (COMMA? DECIMAL TO DECIMAL| COMMA? DECIMAL )+ ) (COMMA? MAX_MEMORY_PERCENT EQUAL max_memory_percent=DECIMAL)? (COMMA? MAX_PROCESSES EQUAL max_processes=DECIMAL)? RR_BRACKET ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-fulltext-catalog-transact-sql alter_fulltext_catalog : ALTER FULLTEXT CATALOG catalog_name=id (REBUILD (WITH ACCENT_SENSITIVITY EQUAL (ON|OFF) )? | REORGANIZE | AS DEFAULT ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-fulltext-catalog-transact-sql create_fulltext_catalog : CREATE FULLTEXT CATALOG catalog_name=id (ON FILEGROUP filegroup=id)? (IN PATH rootpath=STRING)? (WITH ACCENT_SENSITIVITY EQUAL (ON|OFF) )? (AS DEFAULT)? (AUTHORIZATION owner_name=id)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-fulltext-stoplist-transact-sql alter_fulltext_stoplist : ALTER FULLTEXT STOPLIST stoplist_name=id (ADD stopword=STRING LANGUAGE (STRING|DECIMAL|BINARY) | DROP ( stopword=STRING LANGUAGE (STRING|DECIMAL|BINARY) |ALL (STRING|DECIMAL|BINARY) | ALL ) ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-fulltext-stoplist-transact-sql create_fulltext_stoplist : CREATE FULLTEXT STOPLIST stoplist_name=id (FROM ( (database_name=id DOT)? source_stoplist_name=id |SYSTEM STOPLIST ) )? (AUTHORIZATION owner_name=id)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-login-transact-sql alter_login_sql_server : ALTER LOGIN login_name=id ( (ENABLE|DISABLE)? | WITH ( (PASSWORD EQUAL ( password=STRING | password_hash=BINARY HASHED ) ) (MUST_CHANGE|UNLOCK)* )? (OLD_PASSWORD EQUAL old_password=STRING (MUST_CHANGE|UNLOCK)* )? (DEFAULT_DATABASE EQUAL default_database=id)? (DEFAULT_LANGUAGE EQUAL default_laguage=id)? (NAME EQUAL login_name=id)? (CHECK_POLICY EQUAL (ON|OFF) )? (CHECK_EXPIRATION EQUAL (ON|OFF) )? (CREDENTIAL EQUAL credential_name=id)? (NO CREDENTIAL)? | (ADD|DROP) CREDENTIAL credential_name=id ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-login-transact-sql create_login_sql_server : CREATE LOGIN login_name=id ( WITH ( (PASSWORD EQUAL ( password=STRING | password_hash=BINARY HASHED ) ) (MUST_CHANGE|UNLOCK)* )? (COMMA? SID EQUAL sid=BINARY)? (COMMA? DEFAULT_DATABASE EQUAL default_database=id)? (COMMA? DEFAULT_LANGUAGE EQUAL default_laguage=id)? (COMMA? CHECK_EXPIRATION EQUAL (ON|OFF) )? (COMMA? CHECK_POLICY EQUAL (ON|OFF) )? (COMMA? CREDENTIAL EQUAL credential_name=id)? |(FROM (WINDOWS (WITH (COMMA? DEFAULT_DATABASE EQUAL default_database=id)? (COMMA? DEFAULT_LANGUAGE EQUAL default_language=STRING)? ) | CERTIFICATE certname=id | ASYMMETRIC KEY asym_key_name=id ) ) ) ; alter_login_azure_sql : ALTER LOGIN login_name=id ( (ENABLE|DISABLE)? | WITH (PASSWORD EQUAL password=STRING (OLD_PASSWORD EQUAL old_password=STRING)? | NAME EQUAL login_name=id ) ) ; create_login_azure_sql : CREATE LOGIN login_name=id WITH PASSWORD EQUAL STRING (SID EQUAL sid=BINARY)? ; alter_login_azure_sql_dw_and_pdw : ALTER LOGIN login_name=id ( (ENABLE|DISABLE)? | WITH (PASSWORD EQUAL password=STRING (OLD_PASSWORD EQUAL old_password=STRING (MUST_CHANGE|UNLOCK)* )? | NAME EQUAL login_name=id ) ) ; create_login_pdw : CREATE LOGIN loginName=id (WITH ( PASSWORD EQUAL password=STRING (MUST_CHANGE)? (CHECK_POLICY EQUAL (ON|OFF)? )? ) | FROM WINDOWS ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-master-key-transact-sql alter_master_key_sql_server : ALTER MASTER KEY ( (FORCE)? REGENERATE WITH ENCRYPTION BY PASSWORD EQUAL password=STRING |(ADD|DROP) ENCRYPTION BY (SERVICE MASTER KEY | PASSWORD EQUAL encryption_password=STRING) ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-master-key-transact-sql create_master_key_sql_server : CREATE MASTER KEY ENCRYPTION BY PASSWORD EQUAL password=STRING ; alter_master_key_azure_sql : ALTER MASTER KEY ( (FORCE)? REGENERATE WITH ENCRYPTION BY PASSWORD EQUAL password=STRING |ADD ENCRYPTION BY (SERVICE MASTER KEY | PASSWORD EQUAL encryption_password=STRING) | DROP ENCRYPTION BY PASSWORD EQUAL encryption_password=STRING ) ; create_master_key_azure_sql : CREATE MASTER KEY (ENCRYPTION BY PASSWORD EQUAL password=STRING)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-message-type-transact-sql alter_message_type : ALTER MESSAGE TYPE message_type_name=id VALIDATION EQUAL (NONE | EMPTY | WELL_FORMED_XML | VALID_XML WITH SCHEMA COLLECTION schema_collection_name=id) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-partition-function-transact-sql alter_partition_function : ALTER PARTITION FUNCTION partition_function_name=id LR_BRACKET RR_BRACKET (SPLIT|MERGE) RANGE LR_BRACKET DECIMAL RR_BRACKET ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-partition-scheme-transact-sql alter_partition_scheme : ALTER PARTITION SCHEME partition_scheme_name=id NEXT USED (file_group_name=id)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-remote-service-binding-transact-sql alter_remote_service_binding : ALTER REMOTE SERVICE BINDING binding_name=id WITH (USER EQUAL user_name=id)? (COMMA ANONYMOUS EQUAL (ON|OFF) )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-remote-service-binding-transact-sql create_remote_service_binding : CREATE REMOTE SERVICE BINDING binding_name=id (AUTHORIZATION owner_name=id)? TO SERVICE remote_service_name=STRING WITH (USER EQUAL user_name=id)? (COMMA ANONYMOUS EQUAL (ON|OFF) )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-resource-pool-transact-sql create_resource_pool : CREATE RESOURCE POOL pool_name=id (WITH LR_BRACKET (COMMA? MIN_CPU_PERCENT EQUAL DECIMAL)? (COMMA? MAX_CPU_PERCENT EQUAL DECIMAL)? (COMMA? CAP_CPU_PERCENT EQUAL DECIMAL)? (COMMA? AFFINITY SCHEDULER EQUAL (AUTO | LR_BRACKET (COMMA? (DECIMAL|DECIMAL TO DECIMAL) )+ RR_BRACKET | NUMANODE EQUAL LR_BRACKET (COMMA? (DECIMAL|DECIMAL TO DECIMAL) )+ RR_BRACKET ) )? (COMMA? MIN_MEMORY_PERCENT EQUAL DECIMAL)? (COMMA? MAX_MEMORY_PERCENT EQUAL DECIMAL)? (COMMA? MIN_IOPS_PER_VOLUME EQUAL DECIMAL)? (COMMA? MAX_IOPS_PER_VOLUME EQUAL DECIMAL)? RR_BRACKET )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-resource-governor-transact-sql alter_resource_governor : ALTER RESOURCE GOVERNOR ( (DISABLE | RECONFIGURE) | WITH LR_BRACKET CLASSIFIER_FUNCTION EQUAL ( schema_name=id DOT function_name=id | NULL ) RR_BRACKET | RESET STATISTICS | WITH LR_BRACKET MAX_OUTSTANDING_IO_PER_VOLUME EQUAL max_outstanding_io_per_volume=DECIMAL RR_BRACKET ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-role-transact-sql alter_db_role : ALTER ROLE role_name=id ( (ADD|DROP) MEMBER database_principal=id | WITH NAME EQUAL new_role_name=id ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-role-transact-sql create_db_role : CREATE ROLE role_name=id (AUTHORIZATION owner_name = id)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-route-transact-sql create_route : CREATE ROUTE route_name=id (AUTHORIZATION owner_name=id)? WITH (COMMA? SERVICE_NAME EQUAL route_service_name=STRING)? (COMMA? BROKER_INSTANCE EQUAL broker_instance_identifier=STRING)? (COMMA? LIFETIME EQUAL DECIMAL)? COMMA? ADDRESS EQUAL STRING (COMMA MIRROR_ADDRESS EQUAL STRING )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-rule-transact-sql create_rule : CREATE RULE (schema_name=id DOT)? rule_name=id AS search_condition ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-schema-transact-sql alter_schema_sql : ALTER SCHEMA schema_name=id TRANSFER ((OBJECT|TYPE|XML SCHEMA COLLECTION) COLON COLON )? id (DOT id)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-schema-transact-sql create_schema : CREATE SCHEMA (schema_name=id |AUTHORIZATION owner_name=id | schema_name=id AUTHORIZATION owner_name=id ) (create_table |create_view | (GRANT|DENY) (SELECT|INSERT|DELETE|UPDATE) ON (SCHEMA COLON COLON)? object_name=id TO owner_name=id | REVOKE (SELECT|INSERT|DELETE|UPDATE) ON (SCHEMA COLON COLON)? object_name=id FROM owner_name=id )* ; create_schema_azure_sql_dw_and_pdw : CREATE SCHEMA schema_name=id (AUTHORIZATION owner_name=id )? ; alter_schema_azure_sql_dw_and_pdw : ALTER SCHEMA schema_name=id TRANSFER (OBJECT COLON COLON )? id (DOT ID)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-search-property-list-transact-sql create_search_property_list : CREATE SEARCH PROPERTY LIST new_list_name=id (FROM (database_name=id DOT)? source_list_name=id )? (AUTHORIZATION owner_name=id)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-security-policy-transact-sql create_security_policy : CREATE SECURITY POLICY (schema_name=id DOT)? security_policy_name=id (COMMA? ADD (FILTER|BLOCK)? PREDICATE tvf_schema_name=id DOT security_predicate_function_name=id LR_BRACKET (COMMA? column_name_or_arguments=id)+ RR_BRACKET ON table_schema_name=id DOT name=id (COMMA? AFTER (INSERT|UPDATE) | COMMA? BEFORE (UPDATE|DELETE) )* )+ (WITH LR_BRACKET STATE EQUAL (ON|OFF) (SCHEMABINDING (ON|OFF) )? RR_BRACKET )? (NOT FOR REPLICATION)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-sequence-transact-sql alter_sequence : ALTER SEQUENCE (schema_name=id DOT)? sequence_name=id ( RESTART (WITH DECIMAL)? )? (INCREMENT BY sequnce_increment=DECIMAL )? ( MINVALUE DECIMAL| NO MINVALUE)? (MAXVALUE DECIMAL| NO MAXVALUE)? (CYCLE|NO CYCLE)? (CACHE DECIMAL | NO CACHE)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-sequence-transact-sql create_sequence : CREATE SEQUENCE (schema_name=id DOT)? sequence_name=id (AS data_type )? (START WITH DECIMAL)? (INCREMENT BY MINUS? DECIMAL)? (MINVALUE DECIMAL? | NO MINVALUE)? (MAXVALUE DECIMAL? | NO MAXVALUE)? (CYCLE|NO CYCLE)? (CACHE DECIMAL? | NO CACHE)? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-server-audit-transact-sql alter_server_audit : ALTER SERVER AUDIT audit_name=id ( ( TO (FILE ( LR_BRACKET ( COMMA? FILEPATH EQUAL filepath=STRING | COMMA? MAXSIZE EQUAL ( DECIMAL (MB|GB|TB) | UNLIMITED ) | COMMA? MAX_ROLLOVER_FILES EQUAL max_rollover_files=(DECIMAL|UNLIMITED) | COMMA? MAX_FILES EQUAL max_files=DECIMAL | COMMA? RESERVE_DISK_SPACE EQUAL (ON|OFF) )* RR_BRACKET ) | APPLICATION_LOG | SECURITY_LOG ) )? ( WITH LR_BRACKET (COMMA? QUEUE_DELAY EQUAL queue_delay=DECIMAL | COMMA? ON_FAILURE EQUAL (CONTINUE | SHUTDOWN|FAIL_OPERATION) |COMMA? STATE EQUAL (ON|OFF) )* RR_BRACKET )? ( WHERE ( COMMA? (NOT?) event_field_name=id (EQUAL |(LESS GREATER) | (EXCLAMATION EQUAL) | GREATER | (GREATER EQUAL) | LESS | LESS EQUAL ) (DECIMAL | STRING) | COMMA? (AND|OR) NOT? (EQUAL |(LESS GREATER) | (EXCLAMATION EQUAL) | GREATER | (GREATER EQUAL) | LESS | LESS EQUAL) (DECIMAL | STRING) ) )? |REMOVE WHERE | MODIFY NAME EQUAL new_audit_name=id ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-server-audit-transact-sql create_server_audit : CREATE SERVER AUDIT audit_name=id ( ( TO (FILE ( LR_BRACKET ( COMMA? FILEPATH EQUAL filepath=STRING | COMMA? MAXSIZE EQUAL ( DECIMAL (MB|GB|TB) | UNLIMITED ) | COMMA? MAX_ROLLOVER_FILES EQUAL max_rollover_files=(DECIMAL|UNLIMITED) | COMMA? MAX_FILES EQUAL max_files=DECIMAL | COMMA? RESERVE_DISK_SPACE EQUAL (ON|OFF) )* RR_BRACKET ) | APPLICATION_LOG | SECURITY_LOG ) )? ( WITH LR_BRACKET (COMMA? QUEUE_DELAY EQUAL queue_delay=DECIMAL | COMMA? ON_FAILURE EQUAL (CONTINUE | SHUTDOWN|FAIL_OPERATION) |COMMA? STATE EQUAL (ON|OFF) |COMMA? AUDIT_GUID EQUAL audit_guid=id )* RR_BRACKET )? ( WHERE ( COMMA? (NOT?) event_field_name=id (EQUAL |(LESS GREATER) | (EXCLAMATION EQUAL) | GREATER | (GREATER EQUAL) | LESS | LESS EQUAL ) (DECIMAL | STRING) | COMMA? (AND|OR) NOT? (EQUAL |(LESS GREATER) | (EXCLAMATION EQUAL) | GREATER | (GREATER EQUAL) | LESS | LESS EQUAL) (DECIMAL | STRING) ) )? |REMOVE WHERE | MODIFY NAME EQUAL new_audit_name=id ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-server-audit-specification-transact-sql alter_server_audit_specification : ALTER SERVER AUDIT SPECIFICATION audit_specification_name=id (FOR SERVER AUDIT audit_name=id)? ( (ADD|DROP) LR_BRACKET audit_action_group_name=id RR_BRACKET )* (WITH LR_BRACKET STATE EQUAL (ON|OFF) RR_BRACKET )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-server-audit-specification-transact-sql create_server_audit_specification : CREATE SERVER AUDIT SPECIFICATION audit_specification_name=id (FOR SERVER AUDIT audit_name=id)? ( ADD LR_BRACKET audit_action_group_name=id RR_BRACKET )* (WITH LR_BRACKET STATE EQUAL (ON|OFF) RR_BRACKET )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-server-configuration-transact-sql alter_server_configuration : ALTER SERVER CONFIGURATION SET ( (PROCESS AFFINITY (CPU EQUAL (AUTO | (COMMA? DECIMAL | COMMA? DECIMAL TO DECIMAL)+ ) | NUMANODE EQUAL ( COMMA? DECIMAL |COMMA? DECIMAL TO DECIMAL)+ ) | DIAGNOSTICS LOG (ON|OFF|PATH EQUAL (STRING | DEFAULT) |MAX_SIZE EQUAL (DECIMAL MB |DEFAULT)|MAX_FILES EQUAL (DECIMAL|DEFAULT) ) | FAILOVER CLUSTER PROPERTY (VERBOSELOGGING EQUAL (STRING|DEFAULT) |SQLDUMPERFLAGS EQUAL (STRING|DEFAULT) | SQLDUMPERPATH EQUAL (STRING|DEFAULT) | SQLDUMPERTIMEOUT (STRING|DEFAULT) | FAILURECONDITIONLEVEL EQUAL (STRING|DEFAULT) | HEALTHCHECKTIMEOUT EQUAL (DECIMAL|DEFAULT) ) | HADR CLUSTER CONTEXT EQUAL (STRING|LOCAL) | BUFFER POOL EXTENSION (ON LR_BRACKET FILENAME EQUAL STRING COMMA SIZE EQUAL DECIMAL (KB|MB|GB) RR_BRACKET | OFF ) | SET SOFTNUMA (ON|OFF) ) ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-server-role-transact-sql alter_server_role : ALTER SERVER ROLE server_role_name=id ( (ADD|DROP) MEMBER server_principal=id | WITH NAME EQUAL new_server_role_name=id ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-server-role-transact-sql create_server_role : CREATE SERVER ROLE server_role=id (AUTHORIZATION server_principal=id)? ; alter_server_role_pdw : ALTER SERVER ROLE server_role_name=id (ADD|DROP) MEMBER login=id ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-service-transact-sql alter_service : ALTER SERVICE modified_service_name=id (ON QUEUE (schema_name=id DOT) queue_name=id)? (COMMA? (ADD|DROP) modified_contract_name=id)* ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-service-transact-sql create_service : CREATE SERVICE create_service_name=id (AUTHORIZATION owner_name=id)? ON QUEUE (schema_name=id DOT)? queue_name=id ( LR_BRACKET (COMMA? (id|DEFAULT) )+ RR_BRACKET )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-service-master-key-transact-sql alter_service_master_key : ALTER SERVICE MASTER KEY ( FORCE? REGENERATE | (WITH (OLD_ACCOUNT EQUAL acold_account_name=STRING COMMA OLD_PASSWORD EQUAL old_password=STRING | NEW_ACCOUNT EQUAL new_account_name=STRING COMMA NEW_PASSWORD EQUAL new_password=STRING)? ) ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-symmetric-key-transact-sql alter_symmetric_key : ALTER SYMMETRIC KEY key_name=id ( (ADD|DROP) ENCRYPTION BY (CERTIFICATE certificate_name=id | PASSWORD EQUAL password=STRING | SYMMETRIC KEY symmetric_key_name=id | ASYMMETRIC KEY Asym_key_name=id ) ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-symmetric-key-transact-sql create_symmetric_key : ALTER SYMMETRIC KEY key_name=id (AUTHORIZATION owner_name=id)? (FROM PROVIDER provider_name=id)? (WITH ( (KEY_SOURCE EQUAL key_pass_phrase=STRING | ALGORITHM EQUAL (DES | TRIPLE_DES | TRIPLE_DES_3KEY | RC2 | RC4 | RC4_128 | DESX | AES_128 | AES_192 | AES_256) | IDENTITY_VALUE EQUAL identity_phrase=STRING | PROVIDER_KEY_NAME EQUAL provider_key_name=STRING | CREATION_DISPOSITION EQUAL (CREATE_NEW|OPEN_EXISTING) ) | ENCRYPTION BY ( CERTIFICATE certificate_name=id | PASSWORD EQUAL password=STRING | SYMMETRIC KEY symmetric_key_name=id | ASYMMETRIC KEY asym_key_name=id ) ) ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-synonym-transact-sql create_synonym : CREATE SYNONYM (schema_name_1=id DOT )? synonym_name=id FOR ( (server_name=id DOT )? (database_name=id DOT)? (schema_name_2=id DOT)? object_name=id | (database_or_schema2=id DOT)? (schema_id_2_or_object_name=id DOT)? ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-user-transact-sql alter_user : ALTER USER username=id WITH (COMMA? NAME EQUAL newusername=id | COMMA? DEFAULT_SCHEMA EQUAL ( schema_name=id |NULL ) | COMMA? LOGIN EQUAL loginame=id | COMMA? PASSWORD EQUAL STRING (OLD_PASSWORD EQUAL STRING)+ | COMMA? DEFAULT_LANGUAGE EQUAL (NONE| lcid=DECIMAL| language_name_or_alias=id) | COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON|OFF) )+ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-user-transact-sql create_user : CREATE USER user_name=id ( (FOR|FROM) LOGIN login_name=id )? ( WITH (COMMA? DEFAULT_SCHEMA EQUAL schema_name=id |COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON|OFF) )* )? | CREATE USER ( windows_principal=id (WITH (COMMA? DEFAULT_SCHEMA EQUAL schema_name=id |COMMA? DEFAULT_LANGUAGE EQUAL (NONE |DECIMAL |language_name_or_alias=id ) |COMMA? SID EQUAL BINARY |COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON|OFF) )* )? | user_name=id WITH PASSWORD EQUAL password=STRING (COMMA? DEFAULT_SCHEMA EQUAL schema_name=id |COMMA? DEFAULT_LANGUAGE EQUAL (NONE |DECIMAL |language_name_or_alias=id ) |COMMA? SID EQUAL BINARY |COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON|OFF) )* | Azure_Active_Directory_principal=id FROM EXTERNAL PROVIDER ) | CREATE USER user_name=id ( WITHOUT LOGIN (COMMA? DEFAULT_SCHEMA EQUAL schema_name=id |COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON|OFF) )* | (FOR|FROM) CERTIFICATE cert_name=id | (FOR|FROM) ASYMMETRIC KEY asym_key_name=id ) | CREATE USER user_name=id ; create_user_azure_sql_dw : CREATE USER user_name=id ( (FOR|FROM) LOGIN login_name=id | WITHOUT LOGIN )? ( WITH DEFAULT_SCHEMA EQUAL schema_name=id)? | CREATE USER Azure_Active_Directory_principal=id FROM EXTERNAL PROVIDER ( WITH DEFAULT_SCHEMA EQUAL schema_name=id)? ; alter_user_azure_sql : ALTER USER username=id WITH (COMMA? NAME EQUAL newusername=id | COMMA? DEFAULT_SCHEMA EQUAL schema_name=id | COMMA? LOGIN EQUAL loginame=id | COMMA? ALLOW_ENCRYPTED_VALUE_MODIFICATIONS EQUAL (ON|OFF) )+ ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-workload-group-transact-sql alter_workload_group : ALTER WORKLOAD GROUP (workload_group_group_name=id |DEFAULT_DOUBLE_QUOTE ) (WITH LR_BRACKET (IMPORTANCE EQUAL (LOW|MEDIUM|HIGH) | COMMA? REQUEST_MAX_MEMORY_GRANT_PERCENT EQUAL request_max_memory_grant=DECIMAL | COMMA? REQUEST_MAX_CPU_TIME_SEC EQUAL request_max_cpu_time_sec=DECIMAL | REQUEST_MEMORY_GRANT_TIMEOUT_SEC EQUAL request_memory_grant_timeout_sec=DECIMAL | MAX_DOP EQUAL max_dop=DECIMAL | GROUP_MAX_REQUESTS EQUAL group_max_requests=DECIMAL)+ RR_BRACKET )? (USING (workload_group_pool_name=id | DEFAULT_DOUBLE_QUOTE) )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-workload-group-transact-sql create_workload_group : CREATE WORKLOAD GROUP workload_group_group_name=id (WITH LR_BRACKET (IMPORTANCE EQUAL (LOW|MEDIUM|HIGH) | COMMA? REQUEST_MAX_MEMORY_GRANT_PERCENT EQUAL request_max_memory_grant=DECIMAL | COMMA? REQUEST_MAX_CPU_TIME_SEC EQUAL request_max_cpu_time_sec=DECIMAL | REQUEST_MEMORY_GRANT_TIMEOUT_SEC EQUAL request_memory_grant_timeout_sec=DECIMAL | MAX_DOP EQUAL max_dop=DECIMAL | GROUP_MAX_REQUESTS EQUAL group_max_requests=DECIMAL)+ RR_BRACKET )? (USING (workload_group_pool_name=id | DEFAULT_DOUBLE_QUOTE)? (COMMA? EXTERNAL external_pool_name=id | DEFAULT_DOUBLE_QUOTE)? )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-xml-schema-collection-transact-sql create_xml_schema_collection : CREATE XML SCHEMA COLLECTION (relational_schema=id DOT)? sql_identifier=id AS (STRING|id|LOCAL_ID) ; create_queue : CREATE QUEUE (full_table_name | queue_name=id) queue_settings? (ON filegroup=id | DEFAULT)? ; queue_settings : WITH (STATUS EQUAL (ON | OFF) COMMA?)? (RETENTION EQUAL (ON | OFF) COMMA?)? (ACTIVATION LR_BRACKET ( ( (STATUS EQUAL (ON | OFF) COMMA? )? (PROCEDURE_NAME EQUAL func_proc_name_database_schema COMMA?)? (MAX_QUEUE_READERS EQUAL max_readers=DECIMAL COMMA?)? (EXECUTE AS (SELF | user_name=STRING | OWNER) COMMA?)? ) | DROP ) RR_BRACKET COMMA? )? (POISON_MESSAGE_HANDLING LR_BRACKET (STATUS EQUAL (ON | OFF)) RR_BRACKET )? ; alter_queue : ALTER QUEUE (full_table_name | queue_name=id) (queue_settings | queue_action) ; queue_action : REBUILD ( WITH LR_BRACKET queue_rebuild_options RR_BRACKET)? | REORGANIZE (WITH LOB_COMPACTION EQUAL (ON | OFF))? | MOVE TO (id | DEFAULT) ; queue_rebuild_options : MAXDOP EQUAL DECIMAL ; create_contract : CREATE CONTRACT contract_name (AUTHORIZATION owner_name=id)? LR_BRACKET ((message_type_name=id | DEFAULT) SENT BY (INITIATOR | TARGET | ANY ) COMMA?)+ RR_BRACKET ; conversation_statement : begin_conversation_timer | begin_conversation_dialog | end_conversation | get_conversation | send_conversation | waitfor_conversation ; message_statement : CREATE MESSAGE TYPE message_type_name=id (AUTHORIZATION owner_name=id)? (VALIDATION EQUAL (NONE | EMPTY | WELL_FORMED_XML | VALID_XML WITH SCHEMA COLLECTION schema_collection_name=id)) ; // DML // https://docs.microsoft.com/en-us/sql/t-sql/statements/merge-transact-sql // note that there's a limit on number of when_matches but it has to be done runtime due to different ordering of statements allowed merge_statement : with_expression? MERGE (TOP '(' expression ')' PERCENT?)? INTO? ddl_object insert_with_table_hints? as_table_alias? USING table_sources ON search_condition when_matches+ output_clause? option_clause? ';' ; when_matches : (WHEN MATCHED (AND search_condition)? THEN merge_matched)+ | (WHEN NOT MATCHED (BY TARGET)? (AND search_condition)? THEN merge_not_matched) | (WHEN NOT MATCHED BY SOURCE (AND search_condition)? THEN merge_matched)+ ; merge_matched : UPDATE SET update_elem_merge (',' update_elem_merge)* | DELETE ; merge_not_matched : INSERT ('(' column_name_list ')')? (table_value_constructor | DEFAULT VALUES) ; // https://msdn.microsoft.com/en-us/library/ms189835.aspx delete_statement : with_expression? DELETE (TOP '(' expression ')' PERCENT? | TOP DECIMAL)? FROM? delete_statement_from insert_with_table_hints? output_clause? (FROM table_sources)? (WHERE (search_condition | CURRENT OF (GLOBAL? cursor_name | cursor_var=LOCAL_ID)))? for_clause? option_clause? ';'? ; delete_statement_from : ddl_object | table_alias | rowset_function_limited | table_var=LOCAL_ID ; // https://msdn.microsoft.com/en-us/library/ms174335.aspx insert_statement : with_expression? INSERT (TOP '(' expression ')' PERCENT?)? INTO? (ddl_object | rowset_function_limited) insert_with_table_hints? ('(' insert_column_name_list ')')? output_clause? insert_statement_value for_clause? option_clause? ';'? ; insert_statement_value : table_value_constructor | derived_table | execute_statement | DEFAULT VALUES ; receive_statement : '('? RECEIVE (ALL | DISTINCT | top_clause | '*') (LOCAL_ID '=' expression ','?)* FROM full_table_name (INTO table_variable=id (WHERE where=search_condition))? ')'? ; // https://msdn.microsoft.com/en-us/library/ms189499.aspx select_statement_standalone : with_expression? select_statement ; select_statement : query_expression order_by_clause? for_clause? option_clause? ';'? ; time : (LOCAL_ID | constant) ; // https://msdn.microsoft.com/en-us/library/ms177523.aspx update_statement : with_expression? UPDATE (TOP '(' expression ')' PERCENT?)? (ddl_object | rowset_function_limited) with_table_hints? SET update_elem (',' update_elem)* output_clause? (FROM table_sources)? (WHERE (search_condition | CURRENT OF (GLOBAL? cursor_name | cursor_var=LOCAL_ID)))? for_clause? option_clause? ';'? ; // https://msdn.microsoft.com/en-us/library/ms177564.aspx output_clause : OUTPUT output_dml_list_elem (',' output_dml_list_elem)* (INTO (LOCAL_ID | table_name) ('(' column_name_list ')')? )? ; output_dml_list_elem : (output_column_name | expression) as_column_alias? // TODO: scalar_expression ; output_column_name : (DELETED | INSERTED | table_name) '.' ('*' | id) | DOLLAR_ACTION ; // DDL // https://msdn.microsoft.com/en-ie/library/ms176061.aspx create_database : CREATE DATABASE (database=id) ( CONTAINMENT '=' ( NONE | PARTIAL ) )? ( ON PRIMARY? database_file_spec ( ',' database_file_spec )* )? ( LOG ON database_file_spec ( ',' database_file_spec )* )? ( COLLATE collation_name = id )? ( WITH create_database_option ( ',' create_database_option )* )? ; // https://msdn.microsoft.com/en-us/library/ms188783.aspx create_index : CREATE UNIQUE? clustered? INDEX id ON table_name '(' column_name_list_with_order ')' (INCLUDE '(' column_name_list ')' )? (WHERE where=search_condition)? (index_options)? (ON id)? ';'? ; create_xml_index : CREATE PRIMARY? XML INDEX id ON table_name '(' id ')' (USING XML INDEX id (FOR (VALUE | PATH | PROPERTY)?)?)? index_options? ';'? ; // https://msdn.microsoft.com/en-us/library/ms187926(v=sql.120).aspx create_or_alter_procedure : ((CREATE (OR ALTER)?) | ALTER) proc=(PROC | PROCEDURE) procName=func_proc_name_schema (';' DECIMAL)? ('('? procedure_param (',' procedure_param)* ')'?)? (WITH procedure_option (',' procedure_option)*)? (FOR REPLICATION)? AS sql_clauses* ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-trigger-transact-sql create_or_alter_trigger : create_or_alter_dml_trigger | create_or_alter_ddl_trigger ; create_or_alter_dml_trigger : ((CREATE (OR ALTER)?) | ALTER) TRIGGER simple_name ON table_name (WITH dml_trigger_option (',' dml_trigger_option)* )? (FOR | AFTER | INSTEAD OF) dml_trigger_operation (',' dml_trigger_operation)* (WITH APPEND)? (NOT FOR REPLICATION)? AS sql_clauses+ ; dml_trigger_option : ENCRYPTION | execute_clause ; dml_trigger_operation : (INSERT | UPDATE | DELETE) ; create_or_alter_ddl_trigger : ((CREATE (OR ALTER)?) | ALTER) TRIGGER simple_name ON (ALL SERVER | DATABASE) (WITH dml_trigger_option (',' dml_trigger_option)* )? (FOR | AFTER) ddl_trigger_operation (',' dml_trigger_operation)* AS sql_clauses+ ; ddl_trigger_operation : simple_id ; // https://msdn.microsoft.com/en-us/library/ms186755.aspx create_or_alter_function : ((CREATE (OR ALTER)?) | ALTER) FUNCTION funcName=func_proc_name_schema (('(' procedure_param (',' procedure_param)* ')') | '(' ')') //must have (), but can be empty (func_body_returns_select | func_body_returns_table | func_body_returns_scalar) ';'? ; func_body_returns_select : RETURNS TABLE (WITH function_option (',' function_option)*)? AS? RETURN ('(' select_statement_standalone ')' | select_statement_standalone) ; func_body_returns_table : RETURNS LOCAL_ID table_type_definition (WITH function_option (',' function_option)*)? AS? BEGIN sql_clauses* RETURN ';'? END ';'? ; func_body_returns_scalar : RETURNS data_type (WITH function_option (',' function_option)*)? AS? BEGIN sql_clauses* RETURN ret=expression ';'? END ; procedure_param : LOCAL_ID AS? (type_schema=id '.')? data_type VARYING? ('=' default_val=default_value)? (OUT | OUTPUT | READONLY)? ; procedure_option : ENCRYPTION | RECOMPILE | execute_clause ; function_option : ENCRYPTION | SCHEMABINDING | RETURNS NULL ON NULL INPUT | CALLED ON NULL INPUT | execute_clause ; // https://msdn.microsoft.com/en-us/library/ms188038.aspx create_statistics : CREATE STATISTICS id ON table_name '(' column_name_list ')' (WITH (FULLSCAN | SAMPLE DECIMAL (PERCENT | ROWS) | STATS_STREAM) (',' NORECOMPUTE)? (',' INCREMENTAL EQUAL on_off)? )? ';'? ; update_statistics : UPDATE (INDEX | ALL)? STATISTICS full_table_name id? (USING DECIMAL VALUES)? ; // https://msdn.microsoft.com/en-us/library/ms174979.aspx create_table : CREATE TABLE table_name '(' column_def_table_constraints (','? table_indices)* ','? ')' (LOCK simple_id)? table_options* (ON id | DEFAULT)? (TEXTIMAGE_ON id | DEFAULT)?';'? ; table_indices : INDEX id (UNIQUE | CLUSTERED | NONCLUSTERED)? '(' column_name_list_with_order ')' index_options? (ON id)? ; table_options : WITH ('(' index_option (',' index_option)* ')' | index_option (',' index_option)*) ; // https://msdn.microsoft.com/en-us/library/ms187956.aspx create_view : CREATE VIEW simple_name ('(' column_name_list ')')? (WITH view_attribute (',' view_attribute)*)? AS select_statement_standalone (WITH CHECK OPTION)? ';'? ; view_attribute : ENCRYPTION | SCHEMABINDING | VIEW_METADATA ; // https://msdn.microsoft.com/en-us/library/ms190273.aspx alter_table : ALTER TABLE table_name (SET '(' LOCK_ESCALATION '=' (AUTO | TABLE | DISABLE) ')' | ADD column_def_table_constraints | ALTER COLUMN column_definition | DROP COLUMN id (',' id)* | DROP CONSTRAINT constraint=id | WITH CHECK ADD CONSTRAINT constraint=id FOREIGN KEY '(' fk = column_name_list ')' REFERENCES table_name '(' pk = column_name_list')' | CHECK CONSTRAINT constraint=id | (ENABLE | DISABLE) TRIGGER id? | REBUILD table_options) ';'? ; // https://msdn.microsoft.com/en-us/library/ms174269.aspx alter_database : ALTER DATABASE (database=id | CURRENT) (MODIFY NAME '=' new_name=id | COLLATE collation=id | SET database_optionspec (WITH termination)? ) ';'? ; // https://msdn.microsoft.com/en-us/library/bb522682.aspx // Runtime check. database_optionspec : auto_option | change_tracking_option | containment_option | cursor_option | database_mirroring_option | date_correlation_optimization_option | db_encryption_option | db_state_option | db_update_option | db_user_access_option | delayed_durability_option | external_access_option | FILESTREAM database_filestream_option | hadr_options | mixed_page_allocation_option | parameterization_option // | query_store_options | recovery_option // | remote_data_archive_option | service_broker_option | snapshot_option | sql_option | target_recovery_time_option | termination ; auto_option : AUTO_CLOSE on_off | AUTO_CREATE_STATISTICS OFF | ON ( INCREMENTAL EQUAL ON | OFF ) | AUTO_SHRINK on_off | AUTO_UPDATE_STATISTICS on_off | AUTO_UPDATE_STATISTICS_ASYNC (ON | OFF ) ; change_tracking_option : CHANGE_TRACKING EQUAL ( OFF | ON (change_tracking_option_list (',' change_tracking_option_list)*)* ) ; change_tracking_option_list : AUTO_CLEANUP EQUAL on_off | CHANGE_RETENTION EQUAL ( DAYS | HOURS | MINUTES ) ; containment_option : CONTAINMENT EQUAL ( NONE | PARTIAL ) ; cursor_option : CURSOR_CLOSE_ON_COMMIT on_off | CURSOR_DEFAULT ( LOCAL | GLOBAL ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-endpoint-transact-sql alter_endpoint : ALTER ENDPOINT endpointname=id (AUTHORIZATION login=id)? ( STATE EQUAL ( state=STARTED | state=STOPPED | state=DISABLED ) )? AS TCP LR_BRACKET LISTENER_PORT EQUAL port=DECIMAL ( COMMA LISTENER_IP EQUAL (ALL | IPV4_ADDR | IPV6_ADDR | STRING) )? RR_BRACKET (TSQL | FOR SERVICE_BROKER LR_BRACKET AUTHENTICATION EQUAL ( WINDOWS ( NTLM |KERBEROS | NEGOTIATE )? (CERTIFICATE cert_name=id)? | CERTIFICATE cert_name=id WINDOWS? ( NTLM |KERBEROS | NEGOTIATE )? ) ( COMMA? ENCRYPTION EQUAL ( DISABLED |SUPPORTED | REQUIRED ) ( ALGORITHM ( AES | RC4 | AES RC4 | RC4 AES ) )? )? ( COMMA? MESSAGE_FORWARDING EQUAL ( ENABLED | DISABLED ) )? ( COMMA? MESSAGE_FORWARD_SIZE EQUAL DECIMAL)? RR_BRACKET | FOR DATABASE_MIRRORING LR_BRACKET AUTHENTICATION EQUAL ( WINDOWS ( NTLM |KERBEROS | NEGOTIATE )? (CERTIFICATE cert_name=id)? | CERTIFICATE cert_name=id WINDOWS? ( NTLM |KERBEROS | NEGOTIATE )? ) ( COMMA? ENCRYPTION EQUAL ( DISABLED |SUPPORTED | REQUIRED ) ( ALGORITHM ( AES | RC4 | AES RC4 | RC4 AES ) )? )? COMMA? ROLE EQUAL ( WITNESS | PARTNER | ALL ) RR_BRACKET ) ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/create-endpoint-transact-sql // todo: not implemented /* Will visit later */ database_mirroring_option : mirroring_set_option ; mirroring_set_option : mirroring_partner partner_option | mirroring_witness witness_option ; mirroring_partner : PARTNER ; mirroring_witness : WITNESS ; witness_partner_equal : EQUAL ; partner_option : witness_partner_equal partner_server | FAILOVER | FORCE_SERVICE_ALLOW_DATA_LOSS | OFF | RESUME | SAFETY (FULL | OFF ) | SUSPEND | TIMEOUT DECIMAL ; witness_option : witness_partner_equal witness_server | OFF ; witness_server : partner_server ; partner_server : partner_server_tcp_prefix host mirroring_host_port_seperator port_number ; mirroring_host_port_seperator : COLON ; partner_server_tcp_prefix : TCP COLON DOUBLE_FORWARD_SLASH ; port_number : port=DECIMAL ; host : id DOT host | (id DOT |id) ; date_correlation_optimization_option : DATE_CORRELATION_OPTIMIZATION on_off ; db_encryption_option : ENCRYPTION on_off ; db_state_option : ( ONLINE | OFFLINE | EMERGENCY ) ; db_update_option : READ_ONLY | READ_WRITE ; db_user_access_option : SINGLE_USER | RESTRICTED_USER | MULTI_USER ; delayed_durability_option : DELAYED_DURABILITY EQUAL ( DISABLED | ALLOWED | FORCED ) ; external_access_option : DB_CHAINING on_off | TRUSTWORTHY on_off | DEFAULT_LANGUAGE EQUAL ( id | STRING ) | DEFAULT_FULLTEXT_LANGUAGE EQUAL ( id | STRING ) | NESTED_TRIGGERS EQUAL ( OFF | ON ) | TRANSFORM_NOISE_WORDS EQUAL ( OFF | ON ) | TWO_DIGIT_YEAR_CUTOFF EQUAL DECIMAL ; hadr_options : HADR ( ( AVAILABILITY GROUP EQUAL availability_group_name=id | OFF ) |(SUSPEND|RESUME) ) ; mixed_page_allocation_option : MIXED_PAGE_ALLOCATION ( OFF | ON ) ; parameterization_option : PARAMETERIZATION ( SIMPLE | FORCED ) ; recovery_option : RECOVERY ( FULL | BULK_LOGGED | SIMPLE ) | TORN_PAGE_DETECTION on_off | PAGE_VERIFY ( CHECKSUM | TORN_PAGE_DETECTION | NONE ) ; service_broker_option: ENABLE_BROKER | DISABLE_BROKER | NEW_BROKER | ERROR_BROKER_CONVERSATIONS | HONOR_BROKER_PRIORITY on_off ; snapshot_option : ALLOW_SNAPSHOT_ISOLATION on_off | READ_COMMITTED_SNAPSHOT (ON | OFF ) | MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT = (ON | OFF ) ; sql_option : ANSI_NULL_DEFAULT on_off | ANSI_NULLS on_off | ANSI_PADDING on_off | ANSI_WARNINGS on_off | ARITHABORT on_off | COMPATIBILITY_LEVEL EQUAL DECIMAL | CONCAT_NULL_YIELDS_NULL on_off | NUMERIC_ROUNDABORT on_off | QUOTED_IDENTIFIER on_off | RECURSIVE_TRIGGERS on_off ; target_recovery_time_option : TARGET_RECOVERY_TIME EQUAL DECIMAL ( SECONDS | MINUTES ) ; termination : ROLLBACK AFTER seconds = DECIMAL | ROLLBACK IMMEDIATE | NO_WAIT ; // https://msdn.microsoft.com/en-us/library/ms176118.aspx drop_index : DROP INDEX (IF EXISTS)? ( drop_relational_or_xml_or_spatial_index (',' drop_relational_or_xml_or_spatial_index)* | drop_backward_compatible_index (',' drop_backward_compatible_index)* ) ';'? ; drop_relational_or_xml_or_spatial_index : index_name=id ON full_table_name ; drop_backward_compatible_index : (owner_name=id '.')? table_or_view_name=id '.' index_name=id ; // https://msdn.microsoft.com/en-us/library/ms174969.aspx drop_procedure : DROP proc=(PROC | PROCEDURE) (IF EXISTS)? func_proc_name_schema (',' func_proc_name_schema)* ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/drop-trigger-transact-sql drop_trigger : drop_dml_trigger | drop_ddl_trigger ; drop_dml_trigger : DROP TRIGGER (IF EXISTS)? simple_name (',' simple_name)* ';'? ; drop_ddl_trigger : DROP TRIGGER (IF EXISTS)? simple_name (',' simple_name)* ON (DATABASE | ALL SERVER) ';'? ; // https://msdn.microsoft.com/en-us/library/ms190290.aspx drop_function : DROP FUNCTION (IF EXISTS)? func_proc_name_schema (',' func_proc_name_schema)* ';'? ; // https://msdn.microsoft.com/en-us/library/ms175075.aspx drop_statistics : DROP STATISTICS (COMMA? (table_name '.')? name=id)+ ';' ; // https://msdn.microsoft.com/en-us/library/ms173790.aspx drop_table : DROP TABLE (IF EXISTS)? table_name ';'? ; // https://msdn.microsoft.com/en-us/library/ms173492.aspx drop_view : DROP VIEW (IF EXISTS)? simple_name (',' simple_name)* ';'? ; create_type : CREATE TYPE name = simple_name (FROM data_type default_value)? (AS TABLE LR_BRACKET column_def_table_constraints RR_BRACKET)? ; drop_type: DROP TYPE ( IF EXISTS )? name = simple_name ; rowset_function_limited : openquery | opendatasource ; // https://msdn.microsoft.com/en-us/library/ms188427(v=sql.120).aspx openquery : OPENQUERY '(' linked_server=id ',' query=STRING ')' ; // https://msdn.microsoft.com/en-us/library/ms179856.aspx opendatasource : OPENDATASOURCE '(' provider=STRING ',' init=STRING ')' '.' (database=id)? '.' (scheme=id)? '.' (table=id) ; // Other statements. // https://msdn.microsoft.com/en-us/library/ms188927.aspx declare_statement : DECLARE LOCAL_ID AS? table_type_definition ';'? | DECLARE loc+=declare_local (',' loc+=declare_local)* ';'? | DECLARE LOCAL_ID AS? xml_type_definition ';'? | WITH XMLNAMESPACES '(' xml_dec+=xml_declaration (',' xml_dec+=xml_declaration)* ')' ';'? ; xml_declaration : xml_namespace_uri=STRING AS id | DEFAULT STRING ; // https://msdn.microsoft.com/en-us/library/ms181441(v=sql.120).aspx cursor_statement // https://msdn.microsoft.com/en-us/library/ms175035(v=sql.120).aspx : CLOSE GLOBAL? cursor_name ';'? // https://msdn.microsoft.com/en-us/library/ms188782(v=sql.120).aspx | DEALLOCATE GLOBAL? CURSOR? cursor_name ';'? // https://msdn.microsoft.com/en-us/library/ms180169(v=sql.120).aspx | declare_cursor // https://msdn.microsoft.com/en-us/library/ms180152(v=sql.120).aspx | fetch_cursor // https://msdn.microsoft.com/en-us/library/ms190500(v=sql.120).aspx | OPEN GLOBAL? cursor_name ';'? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/backup-transact-sql backup_database : BACKUP DATABASE ( database_name=id ) (READ_WRITE_FILEGROUPS (COMMA? (FILE|FILEGROUP) EQUAL file_or_filegroup=STRING)* )? (COMMA? (FILE|FILEGROUP) EQUAL file_or_filegroup=STRING)* ( TO ( COMMA? logical_device_name=id)+ | TO ( COMMA? (DISK|TAPE|URL) EQUAL (STRING|id) )+ ) ( (MIRROR TO ( COMMA? logical_device_name=id)+ )+ | ( MIRROR TO ( COMMA? (DISK|TAPE|URL) EQUAL (STRING|id) )+ )+ )? (WITH ( COMMA? DIFFERENTIAL | COMMA? COPY_ONLY | COMMA? (COMPRESSION|NO_COMPRESSION) | COMMA? DESCRIPTION EQUAL (STRING|id) | COMMA? NAME EQUAL backup_set_name=id | COMMA? CREDENTIAL | COMMA? FILE_SNAPSHOT | COMMA? (EXPIREDATE EQUAL (STRING|id) | RETAINDAYS EQUAL (DECIMAL|id) ) | COMMA? (NOINIT|INIT) | COMMA? (NOSKIP|SKIP_KEYWORD) | COMMA? (NOFORMAT|FORMAT) | COMMA? MEDIADESCRIPTION EQUAL (STRING|id) | COMMA? MEDIANAME EQUAL (medianame=STRING) | COMMA? BLOCKSIZE EQUAL (DECIMAL|id) | COMMA? BUFFERCOUNT EQUAL (DECIMAL|id) | COMMA? MAXTRANSFER EQUAL (DECIMAL|id) | COMMA? (NO_CHECKSUM|CHECKSUM) | COMMA? (STOP_ON_ERROR|CONTINUE_AFTER_ERROR) | COMMA? RESTART | COMMA? STATS (EQUAL stats_percent=DECIMAL)? | COMMA? (REWIND|NOREWIND) | COMMA? (LOAD|NOUNLOAD) | COMMA? ENCRYPTION LR_BRACKET ALGORITHM EQUAL (AES_128 | AES_192 | AES_256 | TRIPLE_DES_3KEY ) COMMA SERVER CERTIFICATE EQUAL (encryptor_name=id | SERVER ASYMMETRIC KEY EQUAL encryptor_name=id ) )* )? ; backup_log : BACKUP LOG ( database_name=id ) ( TO ( COMMA? logical_device_name=id)+ | TO ( COMMA? (DISK|TAPE|URL) EQUAL (STRING|id) )+ ) ( (MIRROR TO ( COMMA? logical_device_name=id)+ )+ | ( MIRROR TO ( COMMA? (DISK|TAPE|URL) EQUAL (STRING|id) )+ )+ )? (WITH ( COMMA? DIFFERENTIAL | COMMA? COPY_ONLY | COMMA? (COMPRESSION|NO_COMPRESSION) | COMMA? DESCRIPTION EQUAL (STRING|id) | COMMA? NAME EQUAL backup_set_name=id | COMMA? CREDENTIAL | COMMA? FILE_SNAPSHOT | COMMA? (EXPIREDATE EQUAL (STRING|id) | RETAINDAYS EQUAL (DECIMAL|id) ) | COMMA? (NOINIT|INIT) | COMMA? (NOSKIP|SKIP_KEYWORD) | COMMA? (NOFORMAT|FORMAT) | COMMA? MEDIADESCRIPTION EQUAL (STRING|id) | COMMA? MEDIANAME EQUAL (medianame=STRING) | COMMA? BLOCKSIZE EQUAL (DECIMAL|id) | COMMA? BUFFERCOUNT EQUAL (DECIMAL|id) | COMMA? MAXTRANSFER EQUAL (DECIMAL|id) | COMMA? (NO_CHECKSUM|CHECKSUM) | COMMA? (STOP_ON_ERROR|CONTINUE_AFTER_ERROR) | COMMA? RESTART | COMMA? STATS (EQUAL stats_percent=DECIMAL)? | COMMA? (REWIND|NOREWIND) | COMMA? (LOAD|NOUNLOAD) | COMMA? (NORECOVERY| STANDBY EQUAL undo_file_name=STRING) | COMMA? NO_TRUNCATE | COMMA? ENCRYPTION LR_BRACKET ALGORITHM EQUAL (AES_128 | AES_192 | AES_256 | TRIPLE_DES_3KEY ) COMMA SERVER CERTIFICATE EQUAL (encryptor_name=id | SERVER ASYMMETRIC KEY EQUAL encryptor_name=id ) )* )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/backup-certificate-transact-sql backup_certificate : BACKUP CERTIFICATE certname=id TO FILE EQUAL cert_file=STRING ( WITH PRIVATE KEY LR_BRACKET (COMMA? FILE EQUAL private_key_file=STRING |COMMA? ENCRYPTION BY PASSWORD EQUAL encryption_password=STRING |COMMA? DECRYPTION BY PASSWORD EQUAL decryption_pasword=STRING )+ RR_BRACKET )? ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/backup-master-key-transact-sql backup_master_key : BACKUP MASTER KEY TO FILE EQUAL master_key_backup_file=STRING ENCRYPTION BY PASSWORD EQUAL encryption_password=STRING ; // https://docs.microsoft.com/en-us/sql/t-sql/statements/backup-service-master-key-transact-sql backup_service_master_key : BACKUP SERVICE MASTER KEY TO FILE EQUAL service_master_key_backup_file=STRING ENCRYPTION BY PASSWORD EQUAL encryption_password=STRING ; kill_statement : KILL (kill_process | kill_query_notification | kill_stats_job) ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/kill-transact-sql kill_process : (session_id=(DECIMAL|STRING) | UOW) (WITH STATUSONLY)? ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/kill-query-notification-subscription-transact-sql kill_query_notification : QUERY NOTIFICATION SUBSCRIPTION (ALL | subscription_id=DECIMAL) ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/kill-stats-job-transact-sql kill_stats_job : STATS JOB job_id=DECIMAL ; // https://msdn.microsoft.com/en-us/library/ms188332.aspx execute_statement : EXECUTE execute_body ';'? ; execute_body_batch : func_proc_name_server_database_schema (execute_statement_arg (',' execute_statement_arg)*)? ';'? ; execute_body : (return_status=LOCAL_ID '=')? (func_proc_name_server_database_schema | execute_var_string) execute_statement_arg? | '(' execute_var_string ('+' execute_var_string)* ')' (AS? (LOGIN | USER) '=' STRING)? ; execute_statement_arg : execute_statement_arg_unnamed (',' execute_statement_arg) * //Unnamed params can continue unnamed | execute_statement_arg_named (',' execute_statement_arg_named)* //Named can only be continued by unnamed ; execute_statement_arg_named : name=LOCAL_ID '=' value=execute_parameter ; execute_statement_arg_unnamed : value=execute_parameter ; execute_parameter : (constant | LOCAL_ID (OUTPUT | OUT)? | id | DEFAULT | NULL) ; execute_var_string : LOCAL_ID | STRING ; // https://msdn.microsoft.com/en-us/library/ff848791.aspx security_statement // https://msdn.microsoft.com/en-us/library/ms188354.aspx : execute_clause ';'? // https://msdn.microsoft.com/en-us/library/ms187965.aspx | GRANT (ALL PRIVILEGES? | grant_permission ('(' column_name_list ')')?) (ON on_id=table_name)? TO to_principal+=principal_id (',' to_principal+=principal_id)* (WITH GRANT OPTION)? (AS as_principal=principal_id)? ';'? // https://msdn.microsoft.com/en-us/library/ms178632.aspx | REVERT ('(' WITH COOKIE '=' LOCAL_ID ')')? ';'? | open_key | close_key | create_key | create_certificate ; principal_id: | id | PUBLIC ; create_certificate : CREATE CERTIFICATE certificate_name=id (AUTHORIZATION user_name=id)? (FROM existing_keys | generate_new_keys) (ACTIVE FOR BEGIN DIALOG '=' (ON | OFF))? ; existing_keys : ASSEMBLY assembly_name=id | EXECUTABLE? FILE EQUAL path_to_file=STRING (WITH PRIVATE KEY '(' private_key_options ')')? ; private_key_options : (FILE | BINARY) '=' path=STRING (',' (DECRYPTION | ENCRYPTION) BY PASSWORD '=' password=STRING)? ; generate_new_keys : (ENCRYPTION BY PASSWORD '=' password=STRING)? WITH SUBJECT EQUAL certificate_subject_name=STRING (',' date_options)* ; date_options : (START_DATE | EXPIRY_DATE) EQUAL STRING ; open_key : OPEN SYMMETRIC KEY key_name=id DECRYPTION BY decryption_mechanism | OPEN MASTER KEY DECRYPTION BY PASSWORD '=' password=STRING ; close_key : CLOSE SYMMETRIC KEY key_name=id | CLOSE ALL SYMMETRIC KEYS | CLOSE MASTER KEY ; create_key : CREATE MASTER KEY ENCRYPTION BY PASSWORD '=' password=STRING | CREATE SYMMETRIC KEY key_name=id (AUTHORIZATION user_name=id)? (FROM PROVIDER provider_name=id)? WITH ((key_options | ENCRYPTION BY encryption_mechanism)','?)+ ; key_options : KEY_SOURCE EQUAL pass_phrase=STRING | ALGORITHM EQUAL algorithm | IDENTITY_VALUE EQUAL identity_phrase=STRING | PROVIDER_KEY_NAME EQUAL key_name_in_provider=STRING | CREATION_DISPOSITION EQUAL (CREATE_NEW | OPEN_EXISTING) ; algorithm : DES | TRIPLE_DES | TRIPLE_DES_3KEY | RC2 | RC4 | RC4_128 | DESX | AES_128 | AES_192 | AES_256 ; encryption_mechanism : CERTIFICATE certificate_name=id | ASYMMETRIC KEY asym_key_name=id | SYMMETRIC KEY decrypting_Key_name=id | PASSWORD '=' STRING ; decryption_mechanism : CERTIFICATE certificate_name=id (WITH PASSWORD EQUAL STRING)? | ASYMMETRIC KEY asym_key_name=id (WITH PASSWORD EQUAL STRING)? | SYMMETRIC KEY decrypting_Key_name=id | PASSWORD EQUAL STRING ; grant_permission : EXECUTE | VIEW id // DEFINITION | TAKE id // OWNERSHIP | CONTROL id? // SERVER | CREATE (TABLE | VIEW) | SHOWPLAN | IMPERSONATE | SELECT | REFERENCES | INSERT | ALTER (ANY? (id | DATABASE))? ; // https://msdn.microsoft.com/en-us/library/ms190356.aspx // https://msdn.microsoft.com/en-us/library/ms189484.aspx set_statement : SET LOCAL_ID ('.' member_name=id)? '=' expression ';'? | SET LOCAL_ID assignment_operator expression ';'? | SET LOCAL_ID '=' CURSOR declare_set_cursor_common (FOR (READ ONLY | UPDATE (OF column_name_list)?))? ';'? // https://msdn.microsoft.com/en-us/library/ms189837.aspx | set_special ; // https://msdn.microsoft.com/en-us/library/ms174377.aspx transaction_statement // https://msdn.microsoft.com/en-us/library/ms188386.aspx : BEGIN DISTRIBUTED (TRAN | TRANSACTION) (id | LOCAL_ID)? ';'? // https://msdn.microsoft.com/en-us/library/ms188929.aspx | BEGIN (TRAN | TRANSACTION) ((id | LOCAL_ID) (WITH MARK STRING)?)? ';'? // https://msdn.microsoft.com/en-us/library/ms190295.aspx | COMMIT (TRAN | TRANSACTION) ((id | LOCAL_ID) (WITH '(' DELAYED_DURABILITY EQUAL (OFF | ON) ')')?)? ';'? // https://msdn.microsoft.com/en-us/library/ms178628.aspx | COMMIT WORK? ';'? | COMMIT id | ROLLBACK id // https://msdn.microsoft.com/en-us/library/ms181299.aspx | ROLLBACK (TRAN | TRANSACTION) (id | LOCAL_ID)? ';'? // https://msdn.microsoft.com/en-us/library/ms174973.aspx | ROLLBACK WORK? ';'? // https://msdn.microsoft.com/en-us/library/ms188378.aspx | SAVE (TRAN | TRANSACTION) (id | LOCAL_ID)? ';'? ; // https://msdn.microsoft.com/en-us/library/ms188037.aspx go_batch_statement : GO_BATCH (count=DECIMAL)? ; go_statement : GO (count=DECIMAL)? ; // https://msdn.microsoft.com/en-us/library/ms188366.aspx use_statement : USE database=id ';'? ; setuser_statement : SETUSER user=STRING? ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/reconfigure-transact-sql reconfigure_statement : RECONFIGURE (WITH OVERRIDE)? ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/shutdown-transact-sql shutdown_statement : SHUTDOWN (WITH NOWAIT)? ; //These are dbcc commands with strange syntax that doesn't fit the regular dbcc syntax dbcc_special : DBCC SHRINKLOG ('(' SIZE '=' (constant_expression| id | DEFAULT) ')')? ';'? ; dbcc_clause : DBCC name=dbcc_command ('(' expression_list ')')? (WITH dbcc_options)? ';'? ; dbcc_command : simple_id | keyword ; dbcc_options : simple_id (',' simple_id)? ; execute_clause : EXECUTE AS clause=(CALLER | SELF | OWNER | STRING) ; declare_local : LOCAL_ID AS? data_type ('=' expression)? ; table_type_definition : TABLE '(' column_def_table_constraints (','? table_type_indices)* ')' ; table_type_indices : (((PRIMARY KEY | INDEX id) (CLUSTERED | NONCLUSTERED)?) | UNIQUE) '(' column_name_list_with_order ')' | CHECK '(' search_condition ')' ; xml_type_definition : XML '(' ( CONTENT | DOCUMENT )? xml_schema_collection ')' ; xml_schema_collection : ID '.' ID ; column_def_table_constraints : column_def_table_constraint (','? column_def_table_constraint)* ; column_def_table_constraint : column_definition | materialized_column_definition | table_constraint ; // https://msdn.microsoft.com/en-us/library/ms187742.aspx column_definition : id (data_type | AS expression PERSISTED? ) (COLLATE id)? null_notnull? ((CONSTRAINT constraint=id)? null_or_default null_or_default? | IDENTITY ('(' seed=DECIMAL ',' increment=DECIMAL ')')? (NOT FOR REPLICATION)?)? ROWGUIDCOL? column_constraint* ; materialized_column_definition : id (COMPUTE | AS) expression (MATERIALIZED | NOT MATERIALIZED)? ; // https://msdn.microsoft.com/en-us/library/ms186712.aspx column_constraint :(CONSTRAINT constraint=id)? ((PRIMARY KEY | UNIQUE) clustered? index_options? | CHECK (NOT FOR REPLICATION)? '(' search_condition ')' | (FOREIGN KEY)? REFERENCES table_name '(' pk = column_name_list')' on_delete? on_update? | null_notnull) ; // https://msdn.microsoft.com/en-us/library/ms188066.aspx table_constraint : (CONSTRAINT constraint=id)? ((PRIMARY KEY | UNIQUE) clustered? '(' column_name_list_with_order ')' index_options? (ON id)? | CHECK (NOT FOR REPLICATION)? '(' search_condition ')' | DEFAULT '('? (STRING | PLUS | function_call | DECIMAL)+ ')'? FOR id | FOREIGN KEY '(' fk = column_name_list ')' REFERENCES table_name ('(' pk = column_name_list')')? on_delete? on_update?) ; on_delete : ON DELETE (NO ACTION | CASCADE | SET NULL | SET DEFAULT) ; on_update : ON UPDATE (NO ACTION | CASCADE | SET NULL | SET DEFAULT) ; index_options : WITH '(' index_option (',' index_option)* ')' ; // https://msdn.microsoft.com/en-us/library/ms186869.aspx // Id runtime checking. Id in (PAD_INDEX, FILLFACTOR, IGNORE_DUP_KEY, STATISTICS_NORECOMPUTE, ALLOW_ROW_LOCKS, // ALLOW_PAGE_LOCKS, SORT_IN_TEMPDB, ONLINE, MAXDOP, DATA_COMPRESSION, ONLINE). index_option : (simple_id | keyword) '=' (simple_id | keyword | on_off | DECIMAL) ; // https://msdn.microsoft.com/en-us/library/ms180169.aspx declare_cursor : DECLARE cursor_name (CURSOR (declare_set_cursor_common (FOR UPDATE (OF column_name_list)?)?)? | (SEMI_SENSITIVE | INSENSITIVE)? SCROLL? CURSOR FOR select_statement_standalone (FOR (READ ONLY | UPDATE | (OF column_name_list)))? ) ';'? ; declare_set_cursor_common : declare_set_cursor_common_partial* FOR select_statement_standalone ; declare_set_cursor_common_partial : (LOCAL | GLOBAL) | (FORWARD_ONLY | SCROLL) | (STATIC | KEYSET | DYNAMIC | FAST_FORWARD) | (READ_ONLY | SCROLL_LOCKS | OPTIMISTIC) | TYPE_WARNING ; fetch_cursor : FETCH ((NEXT | PRIOR | FIRST | LAST | (ABSOLUTE | RELATIVE) expression)? FROM)? GLOBAL? cursor_name (INTO LOCAL_ID (',' LOCAL_ID)*)? ';'? ; // https://msdn.microsoft.com/en-us/library/ms190356.aspx // Runtime check. set_special : SET id (id | constant_LOCAL_ID | on_off) ';'? | SET STATISTICS (IO | TIME | XML | PROFILE) on_off ';'? | SET ROWCOUNT (LOCAL_ID | DECIMAL) ';'? // https://msdn.microsoft.com/en-us/library/ms173763.aspx | SET TRANSACTION ISOLATION LEVEL (READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SNAPSHOT | SERIALIZABLE | DECIMAL) ';'? // https://msdn.microsoft.com/en-us/library/ms188059.aspx | SET IDENTITY_INSERT table_name on_off ';'? | SET (ANSI_NULLS | QUOTED_IDENTIFIER | ANSI_PADDING | ANSI_WARNINGS | ANSI_DEFAULTS | ANSI_NULL_DFLT_OFF | ANSI_NULL_DFLT_ON | ARITHABORT | ARITHIGNORE | CONCAT_NULL_YIELDS_NULL | CURSOR_CLOSE_ON_COMMIT | FMTONLY | FORCEPLAN | IMPLICIT_TRANSACTIONS | NOCOUNT | NOEXEC | NUMERIC_ROUNDABORT | PARSEONLY | REMOTE_PROC_TRANSACTIONS | SHOWPLAN_ALL | SHOWPLAN_TEXT | SHOWPLAN_XML | XACT_ABORT) on_off | SET modify_method ; constant_LOCAL_ID : constant | LOCAL_ID ; // Expression. // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/expressions-transact-sql // Operator precendence: https://docs.microsoft.com/en-us/sql/t-sql/language-elements/operator-precedence-transact-sql expression : primitive_expression | function_call | expression '.' (value_call | query_call | exist_call | modify_call) | expression COLLATE id | case_expression | full_column_name | bracket_expression | unary_operator_expression | expression op=('*' | '/' | '%') expression | expression op=('+' | '-' | '&' | '^' | '|' | '||') expression | expression time_zone | over_clause ; time_zone : AT_KEYWORD TIME ZONE expression ; primitive_expression : DEFAULT | NULL | LOCAL_ID | constant ; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/case-transact-sql case_expression : CASE caseExpr=expression switch_section+ (ELSE elseExpr=expression)? END | CASE switch_search_condition_section+ (ELSE elseExpr=expression)? END ; unary_operator_expression : '~' expression | op=('+' | '-') expression ; bracket_expression : '(' expression ')' | '(' subquery ')' ; constant_expression : NULL | constant // system functions: https://msdn.microsoft.com/en-us/library/ms187786.aspx | function_call | LOCAL_ID // TODO: remove. | '(' constant_expression ')' ; subquery : select_statement ; // https://msdn.microsoft.com/en-us/library/ms175972.aspx with_expression : WITH ctes+=common_table_expression (',' ctes+=common_table_expression)* ; common_table_expression : expression_name=id ('(' columns=column_name_list ')')? AS '(' cte_query=select_statement ')' ; update_elem : LOCAL_ID '=' full_column_name ('=' | assignment_operator) expression //Combined variable and column update | (full_column_name | LOCAL_ID) ('=' | assignment_operator) expression | udt_column_name=id '.' method_name=id '(' expression_list ')' //| full_column_name '.' WRITE (expression, ) ; update_elem_merge : (full_column_name | LOCAL_ID) ('=' | assignment_operator) expression | udt_column_name=id '.' method_name=id '(' expression_list ')' //| full_column_name '.' WRITE (expression, ) ; search_condition : pred+=predicate_br (log=(OR | AND) pred+=predicate_br)* ; predicate_br : NOT* predicate | NOT* '(' search_condition ')' ; predicate : EXISTS '(' subquery ')' | freetext_predicate | expression comparison_operator expression | expression comparison_operator (ALL | SOME | ANY) '(' subquery ')' | expression NOT* BETWEEN expression AND expression | expression NOT* IN '(' (subquery | expression_list) ')' | expression NOT* LIKE expression (ESCAPE expression)? | expression IS null_notnull ; // Changed union rule to sql_union to avoid union construct with C++ target. Issue reported by person who generates into C++. This individual reports change causes generated code to work query_expression : (query_specification | '(' query_expression ')') | query_specification order_by_clause? unions+=sql_union+ //if using top, order by can be on the "top" side of union :/ ; sql_union : (UNION ALL? | EXCEPT | INTERSECT) (spec=query_specification | ('(' op=query_expression ')')) ; // https://msdn.microsoft.com/en-us/library/ms176104.aspx query_specification : SELECT allOrDistinct=(ALL | DISTINCT)? top=top_clause? columns=select_list // https://msdn.microsoft.com/en-us/library/ms188029.aspx (INTO into=table_name)? (FROM from=table_sources)? (WHERE where=search_condition)? // https://msdn.microsoft.com/en-us/library/ms177673.aspx (GROUP BY groupByAll=ALL? groupBys+=group_by_item (',' groupBys+=group_by_item)*)? (HAVING having=search_condition)? ; // https://msdn.microsoft.com/en-us/library/ms189463.aspx top_clause : TOP (top_percent | top_count) (WITH TIES)? ; top_percent : percent_constant=(REAL | FLOAT | DECIMAL) PERCENT | '(' topper_expression=expression ')' PERCENT ; top_count : count_constant=DECIMAL | '(' topcount_expression=expression ')' ; // https://msdn.microsoft.com/en-us/library/ms188385.aspx order_by_clause : ORDER BY order_bys+=order_by_expression (',' order_bys+=order_by_expression)* (OFFSET offset_exp=expression offset_rows=(ROW | ROWS) (FETCH fetch_offset=(FIRST | NEXT) fetch_exp=expression fetch_rows=(ROW | ROWS) ONLY)?)? ; // https://docs.microsoft.com/en-us/sql/t-sql/queries/select-for-clause-transact-sql for_clause : FOR BROWSE | FOR XML (RAW ('(' STRING ')')? | AUTO) xml_common_directives* (COMMA (XMLDATA | XMLSCHEMA ('(' STRING ')')?))? (COMMA ELEMENTS (XSINIL | ABSENT)?)? | FOR XML EXPLICIT xml_common_directives* (COMMA XMLDATA)? | FOR XML PATH ('(' STRING ')')? xml_common_directives* (COMMA ELEMENTS (XSINIL | ABSENT)?)? | FOR JSON (AUTO | PATH) (COMMA ROOT ('(' STRING ')')?)? (COMMA INCLUDE_NULL_VALUES)? (COMMA WITHOUT_ARRAY_WRAPPER)? ; xml_common_directives : ',' (BINARY_BASE64 | TYPE | ROOT ('(' STRING ')')?) ; order_by_expression : order_by=expression (ascending=ASC | descending=DESC)? ; group_by_item : expression /*| rollup_spec | cube_spec | grouping_sets_spec | grand_total*/ ; option_clause // https://msdn.microsoft.com/en-us/library/ms181714.aspx : OPTION '(' options+=option (',' options+=option)* ')' ; option : FAST number_rows=DECIMAL | (HASH | ORDER) GROUP | (MERGE | HASH | CONCAT) UNION | (LOOP | MERGE | HASH) JOIN | EXPAND VIEWS | FORCE ORDER | IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX | KEEP PLAN | KEEPFIXED PLAN | MAXDOP number_of_processors=DECIMAL | MAXRECURSION number_recursion=DECIMAL | OPTIMIZE FOR '(' optimize_for_arg (',' optimize_for_arg)* ')' | OPTIMIZE FOR UNKNOWN | PARAMETERIZATION (SIMPLE | FORCED) | RECOMPILE | ROBUST PLAN | USE PLAN STRING ; optimize_for_arg : LOCAL_ID (UNKNOWN | '=' (constant | NULL)) ; // https://msdn.microsoft.com/en-us/library/ms176104.aspx select_list : selectElement+=select_list_elem (',' selectElement+=select_list_elem)* ; udt_method_arguments : '(' argument+=execute_var_string (',' argument+=execute_var_string)* ')' ; // https://docs.microsoft.com/ru-ru/sql/t-sql/queries/select-clause-transact-sql asterisk : (table_name '.')? '*' ; column_elem : (full_column_name | '$' IDENTITY | '$' ROWGUID | NULL) as_column_alias? ; udt_elem : udt_column_name=id '.' non_static_attr=id udt_method_arguments as_column_alias? | udt_column_name=id ':' ':' static_attr=id udt_method_arguments? as_column_alias? ; expression_elem : leftAlias=column_alias eq='=' leftAssignment=expression | expressionAs=expression as_column_alias? ; select_list_elem : asterisk | column_elem | udt_elem | LOCAL_ID (assignment_operator | '=') expression | expression_elem ; table_sources : source+=table_source (',' source+=table_source)* ; // https://msdn.microsoft.com/en-us/library/ms177634.aspx table_source : table_source_item_joined | '(' table_source_item_joined ')' ; table_source_item_joined : table_source_item joins+=join_part* ; table_source_item : table_name_with_hint as_table_alias? | full_table_name as_table_alias? | rowset_function as_table_alias? | '(' derived_table ')' (as_table_alias column_alias_list?)? | change_table as_table_alias? | function_call (as_table_alias column_alias_list?)? | loc_id=LOCAL_ID as_table_alias? | nodes_method (as_table_alias column_alias_list?)? | loc_id_call=LOCAL_ID '.' loc_fcall=function_call (as_table_alias column_alias_list?)? | open_xml | open_json | ':' ':' oldstyle_fcall=function_call as_table_alias? // Build-in function (old syntax) ; // https://docs.microsoft.com/en-us/sql/t-sql/functions/openxml-transact-sql open_xml : OPENXML '(' expression ',' expression (',' expression)? ')' (WITH '(' schema_declaration ')' )? as_table_alias? ; open_json : OPENJSON '(' expression (',' expression)? ')' (WITH '(' json_declaration ')' )? as_table_alias? ; json_declaration : json_col+=json_column_declaration (',' json_col+=json_column_declaration)* ; json_column_declaration : column_declaration (AS JSON)? ; schema_declaration : xml_col+=column_declaration (',' xml_col+=column_declaration)* ; column_declaration : id data_type STRING? ; change_table : change_table_changes | change_table_version ; change_table_changes : CHANGETABLE '(' CHANGES changetable=table_name ',' changesid=(NULL | DECIMAL | LOCAL_ID) ')' ; change_table_version : CHANGETABLE '(' VERSION versiontable=table_name ',' pk_columns=full_column_name_list ',' pk_values=select_list ')' ; // https://msdn.microsoft.com/en-us/library/ms191472.aspx join_part // https://msdn.microsoft.com/en-us/library/ms173815(v=sql.120).aspx : join_on | cross_join | apply | pivot | unpivot ; join_on : (inner=INNER? | join_type=(LEFT | RIGHT | FULL) outer=OUTER?) (join_hint=(LOOP | HASH | MERGE | REMOTE))? JOIN source=table_source ON cond=search_condition ; cross_join : CROSS JOIN table_source ; apply : apply_style=(CROSS | OUTER) APPLY source=table_source ; pivot : PIVOT pivot_clause as_table_alias ; unpivot : UNPIVOT unpivot_clause as_table_alias ; pivot_clause : '(' aggregate_windowed_function FOR full_column_name IN column_alias_list ')' ; unpivot_clause : '(' unpivot_exp=expression FOR full_column_name IN '(' full_column_name_list ')' ')' ; full_column_name_list : column+=full_column_name (',' column+=full_column_name)* ; table_name_with_hint : table_name with_table_hints? ; // https://msdn.microsoft.com/en-us/library/ms190312.aspx rowset_function : ( OPENROWSET LR_BRACKET provider_name = STRING COMMA connectionString = STRING COMMA sql = STRING RR_BRACKET ) | ( OPENROWSET '(' BULK data_file=STRING ',' (bulk_option (',' bulk_option)* | id)')' ) ; // runtime check. bulk_option : id '=' bulk_option_value=(DECIMAL | STRING) ; derived_table : subquery | '(' subquery ')' | table_value_constructor | '(' table_value_constructor ')' ; function_call : ranking_windowed_function #RANKING_WINDOWED_FUNC | aggregate_windowed_function #AGGREGATE_WINDOWED_FUNC | analytic_windowed_function #ANALYTIC_WINDOWED_FUNC | scalar_function_name '(' expression_list? ')' #SCALAR_FUNCTION | build_in_functions #BUILT_IN_FUNC | freetext_function #FREE_TEXT ; freetext_function : (CONTAINSTABLE | FREETEXTTABLE) '(' table_name ',' (full_column_name | '(' full_column_name (',' full_column_name)* ')' | '*' ) ',' expression (',' LANGUAGE expression)? (',' expression)? ')' | (SEMANTICSIMILARITYTABLE | SEMANTICKEYPHRASETABLE) '(' table_name ',' (full_column_name | '(' full_column_name (',' full_column_name)* ')' | '*' ) ',' expression ')' | SEMANTICSIMILARITYDETAILSTABLE '(' table_name ',' full_column_name ',' expression ',' full_column_name ',' expression ')' ; freetext_predicate : CONTAINS '(' (full_column_name | '(' full_column_name (',' full_column_name)* ')' | '*' | PROPERTY '(' full_column_name ',' expression ')') ',' expression ')' | FREETEXT '(' table_name ',' (full_column_name | '(' full_column_name (',' full_column_name)* ')' | '*' ) ',' expression (',' LANGUAGE expression)? ')' ; build_in_functions // https://msdn.microsoft.com/en-us/library/ms173784.aspx : BINARY_CHECKSUM '(' '*' ')' #BINARY_CHECKSUM // https://msdn.microsoft.com/en-us/library/hh231076.aspx // https://msdn.microsoft.com/en-us/library/ms187928.aspx | CAST '(' expression AS data_type ')' #CAST | TRY_CAST '(' expression AS data_type ')' #TRY_CAST | CONVERT '(' convert_data_type=data_type ','convert_expression=expression (',' style=expression)? ')' #CONVERT // https://msdn.microsoft.com/en-us/library/ms189788.aspx | CHECKSUM '(' '*' ')' #CHECKSUM // https://msdn.microsoft.com/en-us/library/ms190349.aspx | COALESCE '(' expression_list ')' #COALESCE // https://msdn.microsoft.com/en-us/library/ms188751.aspx | CURRENT_TIMESTAMP #CURRENT_TIMESTAMP // https://msdn.microsoft.com/en-us/library/ms176050.aspx | CURRENT_USER #CURRENT_USER // https://msdn.microsoft.com/en-us/library/ms186819.aspx | DATEADD '(' datepart=ID ',' number=expression ',' date=expression ')' #DATEADD // https://msdn.microsoft.com/en-us/library/ms189794.aspx | DATEDIFF '(' datepart=ID ',' date_first=expression ',' date_second=expression ')' #DATEDIFF // https://msdn.microsoft.com/en-us/library/ms174395.aspx | DATENAME '(' datepart=ID ',' date=expression ')' #DATENAME // https://msdn.microsoft.com/en-us/library/ms174420.aspx | DATEPART '(' datepart=ID ',' date=expression ')' #DATEPART // https://docs.microsoft.com/en-us/sql/t-sql/functions/getdate-transact-sql | GETDATE '(' ')' #GETDATE // https://docs.microsoft.com/en-us/sql/t-sql/functions/getdate-transact-sql | GETUTCDATE '(' ')' #GETUTCDATE // https://msdn.microsoft.com/en-us/library/ms189838.aspx | IDENTITY '(' data_type (',' seed=DECIMAL)? (',' increment=DECIMAL)? ')' #IDENTITY // https://msdn.microsoft.com/en-us/library/bb839514.aspx | MIN_ACTIVE_ROWVERSION '(' ')' #MIN_ACTIVE_ROWVERSION // https://msdn.microsoft.com/en-us/library/ms177562.aspx | NULLIF '(' left=expression ',' right=expression ')' #NULLIF // https://msdn.microsoft.com/fr-fr/library/ms188043.aspx | STUFF '(' str=expression ',' from=DECIMAL ',' to=DECIMAL ',' str_with=expression ')' #STUFF // https://msdn.microsoft.com/en-us/library/ms177587.aspx | SESSION_USER #SESSION_USER // https://msdn.microsoft.com/en-us/library/ms179930.aspx | SYSTEM_USER #SYSTEM_USER | USER #USER // https://msdn.microsoft.com/en-us/library/ms184325.aspx | ISNULL '(' left=expression ',' right=expression ')' #ISNULL // https://docs.microsoft.com/en-us/sql/t-sql/xml/xml-data-type-methods | xml_data_type_methods #XML_DATA_TYPE_FUNC // https://docs.microsoft.com/en-us/sql/t-sql/functions/logical-functions-iif-transact-sql | IIF '(' cond=search_condition ',' left=expression ',' right=expression ')' #IIF | STRING_AGG '(' expr=expression ',' separator=expression ')' (WITHIN GROUP '(' order_by_clause ')')? #STRINGAGG ; xml_data_type_methods : value_method | query_method | exist_method | modify_method ; value_method : (loc_id=LOCAL_ID | value_id=id | eventdata=EVENTDATA | query=query_method | '(' subquery ')') '.' call=value_call ; value_call : VALUE '(' xquery=STRING ',' sqltype=STRING ')' ; query_method : (loc_id=LOCAL_ID | value_id=id | table=full_table_name | '(' subquery ')' ) '.' call=query_call ; query_call : QUERY '(' xquery=STRING ')' ; exist_method : (loc_id=LOCAL_ID | value_id=id | '(' subquery ')') '.' call=exist_call ; exist_call : EXIST '(' xquery=STRING ')' ; modify_method : (loc_id=LOCAL_ID | value_id=id | '(' subquery ')') '.' call=modify_call ; modify_call : MODIFY '(' xml_dml=STRING ')' ; nodes_method : (loc_id=LOCAL_ID | value_id=id | '(' subquery ')') '.' NODES '(' xquery=STRING ')' ; switch_section : WHEN expression THEN expression ; switch_search_condition_section : WHEN search_condition THEN expression ; as_column_alias : AS? column_alias ; as_table_alias : AS? table_alias ; table_alias : id with_table_hints? ; // https://msdn.microsoft.com/en-us/library/ms187373.aspx with_table_hints : WITH? '(' hint+=table_hint (','? hint+=table_hint)* ')' ; // https://msdn.microsoft.com/en-us/library/ms187373.aspx insert_with_table_hints : WITH '(' hint+=table_hint (','? hint+=table_hint)* ')' ; // Id runtime check. Id can be (FORCESCAN, HOLDLOCK, NOLOCK, NOWAIT, PAGLOCK, READCOMMITTED, // READCOMMITTEDLOCK, READPAST, READUNCOMMITTED, REPEATABLEREAD, ROWLOCK, TABLOCK, TABLOCKX // UPDLOCK, XLOCK) table_hint : NOEXPAND? ( INDEX ('(' index_value (',' index_value)* ')' | index_value (',' index_value)*) | INDEX '=' index_value | FORCESEEK ('(' index_value '(' ID (',' ID)* ')' ')')? | SERIALIZABLE | SNAPSHOT | SPATIAL_WINDOW_MAX_CELLS '=' DECIMAL | HOLDLOCK | ID ) ; index_value : id | DECIMAL ; column_alias_list : '(' alias+=column_alias (',' alias+=column_alias)* ')' ; column_alias : id | STRING ; table_value_constructor : VALUES '(' exps+=expression_list ')' (',' '(' exps+=expression_list ')')* ; expression_list : exp+=expression (',' exp+=expression)* ; // https://msdn.microsoft.com/en-us/library/ms189798.aspx ranking_windowed_function : (RANK | DENSE_RANK | ROW_NUMBER) '(' ')' over_clause | NTILE '(' expression ')' over_clause ; // https://msdn.microsoft.com/en-us/library/ms173454.aspx aggregate_windowed_function : agg_func=(AVG | MAX | MIN | SUM | STDEV | STDEVP | VAR | VARP) '(' all_distinct_expression ')' over_clause? | cnt=(COUNT | COUNT_BIG) '(' ('*' | all_distinct_expression) ')' over_clause? | CHECKSUM_AGG '(' all_distinct_expression ')' | GROUPING '(' expression ')' | GROUPING_ID '(' expression_list ')' ; // https://docs.microsoft.com/en-us/sql/t-sql/functions/analytic-functions-transact-sql analytic_windowed_function : (FIRST_VALUE | LAST_VALUE) '(' expression ')' over_clause | (LAG | LEAD) '(' expression (',' expression (',' expression)? )? ')' over_clause | (CUME_DIST | PERCENT_RANK) '(' ')' OVER '(' (PARTITION BY expression_list)? order_by_clause ')' | (PERCENTILE_CONT | PERCENTILE_DISC) '(' expression ')' WITHIN GROUP '(' ORDER BY expression (ASC | DESC)? ')' OVER '(' (PARTITION BY expression_list)? ')' ; all_distinct_expression : (ALL | DISTINCT)? expression ; // https://msdn.microsoft.com/en-us/library/ms189461.aspx over_clause : OVER '(' (PARTITION BY expression_list)? order_by_clause? row_or_range_clause? ')' ; row_or_range_clause : (ROWS | RANGE) window_frame_extent ; window_frame_extent : window_frame_preceding | BETWEEN window_frame_bound AND window_frame_bound ; window_frame_bound : window_frame_preceding | window_frame_following ; window_frame_preceding : UNBOUNDED PRECEDING | DECIMAL PRECEDING | CURRENT ROW ; window_frame_following : UNBOUNDED FOLLOWING | DECIMAL FOLLOWING ; create_database_option : FILESTREAM ( database_filestream_option (',' database_filestream_option)* ) | DEFAULT_LANGUAGE EQUAL ( id | STRING ) | DEFAULT_FULLTEXT_LANGUAGE EQUAL ( id | STRING ) | NESTED_TRIGGERS EQUAL ( OFF | ON ) | TRANSFORM_NOISE_WORDS EQUAL ( OFF | ON ) | TWO_DIGIT_YEAR_CUTOFF EQUAL DECIMAL | DB_CHAINING ( OFF | ON ) | TRUSTWORTHY ( OFF | ON ) ; database_filestream_option : LR_BRACKET ( ( NON_TRANSACTED_ACCESS EQUAL ( OFF | READ_ONLY | FULL ) ) | ( DIRECTORY_NAME EQUAL STRING ) ) RR_BRACKET ; database_file_spec : file_group | file_spec ; file_group : FILEGROUP id ( CONTAINS FILESTREAM )? ( DEFAULT )? ( CONTAINS MEMORY_OPTIMIZED_DATA )? file_spec ( ',' file_spec )* ; file_spec : LR_BRACKET NAME EQUAL ( id | STRING ) ','? FILENAME EQUAL file = STRING ','? ( SIZE EQUAL file_size ','? )? ( MAXSIZE EQUAL (file_size | UNLIMITED )','? )? ( FILEGROWTH EQUAL file_size ','? )? RR_BRACKET ; // Primitive. entity_name : (server=id '.' database=id '.' schema=id '.' | database=id '.' (schema=id)? '.' | schema=id '.')? table=id ; entity_name_for_azure_dw : schema=id | schema=id '.' object_name=id ; entity_name_for_parallel_dw : schema_database=id | schema=id '.' object_name=id ; full_table_name : (server=id '.' database=id '.' schema=id '.' | database=id '.' (schema=id)? '.' | schema=id '.')? table=id ; table_name : (database=id '.' (schema=id)? '.' | schema=id '.')? table=id | (database=id '.' (schema=id)? '.' | schema=id '.')? blocking_hierarchy=BLOCKING_HIERARCHY ; simple_name : (schema=id '.')? name=id ; func_proc_name_schema : ((schema=id) '.')? procedure=id ; func_proc_name_database_schema : database=id? '.' schema=id? '.' procedure=id | func_proc_name_schema ; func_proc_name_server_database_schema : server=id? '.' database=id? '.' schema=id? '.' procedure=id | func_proc_name_database_schema ; ddl_object : full_table_name | LOCAL_ID ; full_column_name : server=id? '.' schema=id? '.' tablename=id? '.' column_name=id | schema=id? '.' tablename=id? '.' column_name=id | tablename=id? '.' column_name=id | column_name=id ; column_name_list_with_order : id (ASC | DESC)? (',' id (ASC | DESC)?)* ; //For some reason, sql server allows any number of prefixes: Here, h is the column: a.b.c.d.e.f.g.h insert_column_name_list : col+=insert_column_id (',' col+=insert_column_id)* ; insert_column_id : (ignore+=id? '.' )* id ; column_name_list : col+=id (',' col+=id)* ; cursor_name : id | LOCAL_ID ; on_off : ON | OFF ; clustered : CLUSTERED | NONCLUSTERED ; null_notnull : NOT? NULL ; null_or_default :(null_notnull | DEFAULT constant_expression (COLLATE id)? (WITH VALUES)?) ; scalar_function_name : func_proc_name_server_database_schema | RIGHT | LEFT | BINARY_CHECKSUM | CHECKSUM ; begin_conversation_timer : BEGIN CONVERSATION TIMER '(' LOCAL_ID ')' TIMEOUT '=' time ';'? ; begin_conversation_dialog : BEGIN DIALOG (CONVERSATION)? dialog_handle=LOCAL_ID FROM SERVICE initiator_service_name=service_name TO SERVICE target_service_name=service_name (',' service_broker_guid=STRING)? ON CONTRACT contract_name (WITH ((RELATED_CONVERSATION | RELATED_CONVERSATION_GROUP) '=' LOCAL_ID ','?)? (LIFETIME '=' (DECIMAL | LOCAL_ID) ','?)? (ENCRYPTION '=' (ON | OFF))? )? ';'? ; contract_name : (id | expression) ; service_name : (id | expression) ; end_conversation : END CONVERSATION conversation_handle=LOCAL_ID ';'? (WITH (ERROR '=' faliure_code=(LOCAL_ID | STRING) DESCRIPTION '=' failure_text=(LOCAL_ID | STRING))? CLEANUP? )? ; waitfor_conversation : WAITFOR? '(' get_conversation ')' (','? TIMEOUT timeout=time)? ';'? ; get_conversation :GET CONVERSATION GROUP conversation_group_id=(STRING | LOCAL_ID) FROM queue=queue_id ';'? ; queue_id : (database_name=id '.' schema_name=id '.' name=id) | id ; send_conversation : SEND ON CONVERSATION conversation_handle=(STRING | LOCAL_ID) MESSAGE TYPE message_type_name=expression ('(' message_body_expression=(STRING | LOCAL_ID) ')' )? ';'? ; // https://msdn.microsoft.com/en-us/library/ms187752.aspx // TODO: implement runtime check or add new tokens. data_type : scaled=(VARCHAR | NVARCHAR | BINARY_KEYWORD | VARBINARY_KEYWORD) '(' MAX ')' | ext_type=id '(' scale=DECIMAL ',' prec=DECIMAL ')' | ext_type=id '(' scale=DECIMAL ')' | ext_type=id IDENTITY ('(' seed=DECIMAL ',' inc=DECIMAL ')')? | double_prec=DOUBLE PRECISION? | unscaled_type=id ; default_value : NULL | DEFAULT | constant ; // https://msdn.microsoft.com/en-us/library/ms179899.aspx constant : STRING // string, datetime or uniqueidentifier | BINARY | sign? DECIMAL | sign? (REAL | FLOAT) // float or decimal | sign? dollar='$' (DECIMAL | FLOAT) // money ; sign : '+' | '-' ; keyword : ABSOLUTE | ACCENT_SENSITIVITY | ACTION | ACTIVATION | ACTIVE | ADDRESS | AES_128 | AES_192 | AES_256 | AFFINITY | AFTER | AGGREGATE | ALGORITHM | ALLOW_ENCRYPTED_VALUE_MODIFICATIONS | ALLOW_SNAPSHOT_ISOLATION | ALLOWED | ANSI_NULL_DEFAULT | ANSI_NULLS | ANSI_PADDING | ANSI_WARNINGS | APPLICATION_LOG | APPLY | ARITHABORT | ASSEMBLY | AT_KEYWORD | AUDIT | AUDIT_GUID | AUTO | AUTO_CLEANUP | AUTO_CLOSE | AUTO_CREATE_STATISTICS | AUTO_SHRINK | AUTO_UPDATE_STATISTICS | AUTO_UPDATE_STATISTICS_ASYNC | AVAILABILITY | AVG | BACKUP_PRIORITY | BEGIN_DIALOG | BIGINT | BINARY_BASE64 | BINARY_CHECKSUM | BINDING | BLOB_STORAGE | BROKER | BROKER_INSTANCE | BULK_LOGGED | CALLER | CAP_CPU_PERCENT | CAST | CATALOG | CATCH | CHANGE_RETENTION | CHANGE_TRACKING | CHECKSUM | CHECKSUM_AGG | CLEANUP | COLLECTION | COLUMN_MASTER_KEY | COMMITTED | COMPATIBILITY_LEVEL | CONCAT | CONCAT_NULL_YIELDS_NULL | CONTENT | CONTROL | COOKIE | COUNT | COUNT_BIG | COUNTER | CPU | CREATE_NEW | CREATION_DISPOSITION | CREDENTIAL | CRYPTOGRAPHIC | CURSOR_CLOSE_ON_COMMIT | CURSOR_DEFAULT | DATA | DATE_CORRELATION_OPTIMIZATION | DATEADD | DATEDIFF | DATENAME | DATEPART | DAYS | DB_CHAINING | DB_FAILOVER | DECRYPTION | DEFAULT_DOUBLE_QUOTE | DEFAULT_FULLTEXT_LANGUAGE | DEFAULT_LANGUAGE | DELAY | DELAYED_DURABILITY | DELETED | DENSE_RANK | DEPENDENTS | DES | DESCRIPTION | DESX | DHCP | DIALOG | DIRECTORY_NAME | DISABLE | DISABLE_BROKER | DISABLED | DISK_DRIVE | DOCUMENT | DYNAMIC | ELEMENTS | EMERGENCY | EMPTY | ENABLE | ENABLE_BROKER | ENCRYPTED_VALUE | ENCRYPTION | ENDPOINT_URL | ERROR_BROKER_CONVERSATIONS | EXCLUSIVE | EXECUTABLE | EXIST | EXPAND | EXPIRY_DATE | EXPLICIT | FAIL_OPERATION | FAILOVER_MODE | FAILURE | FAILURE_CONDITION_LEVEL | FAST | FAST_FORWARD | FILEGROUP | FILEGROWTH | FILEPATH | FILESTREAM | FILTER | FIRST | FIRST_VALUE | FOLLOWING | FORCE | FORCE_FAILOVER_ALLOW_DATA_LOSS | FORCED | FORMAT | FORWARD_ONLY | FULLSCAN | FULLTEXT | GB | GETDATE | GETUTCDATE | GLOBAL | GO | GO_BATCH | GROUP_MAX_REQUESTS | GROUPING | GROUPING_ID | HADR | HASH | HEALTH_CHECK_TIMEOUT | HIGH | HONOR_BROKER_PRIORITY | HOURS | IDENTITY_VALUE | IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX | IMMEDIATE | IMPERSONATE | IMPORTANCE | INCLUDE_NULL_VALUES | INCREMENTAL | INITIATOR | INPUT | INSENSITIVE | INSERTED | INT | IP | ISOLATION | JOB | JSON | KB | KEEP | KEEPFIXED | KEY_SOURCE | KEYS | KEYSET | LAG | LAST | LAST_VALUE | LEAD | LEVEL | LIST | LISTENER | LISTENER_URL | LOB_COMPACTION | LOCAL | LOCATION | LOCK | LOCK_ESCALATION | LOGIN | LOOP | LOW | MANUAL | MARK | MATERIALIZED | MAX | MAX_CPU_PERCENT | MAX_DOP | MAX_FILES | MAX_IOPS_PER_VOLUME | MAX_MEMORY_PERCENT | MAX_PROCESSES | MAX_QUEUE_READERS | MAX_ROLLOVER_FILES | MAXDOP | MAXRECURSION | MAXSIZE | MB | MEDIUM | MEMORY_OPTIMIZED_DATA | MESSAGE | MIN | MIN_ACTIVE_ROWVERSION | MIN_CPU_PERCENT | MIN_IOPS_PER_VOLUME | MIN_MEMORY_PERCENT | MINUTES | MIRROR_ADDRESS | MIXED_PAGE_ALLOCATION | MODE | MODIFY | MOVE | MULTI_USER | NAME | NESTED_TRIGGERS | NEW_ACCOUNT | NEW_BROKER | NEW_PASSWORD | NEXT | NO | NO_TRUNCATE | NO_WAIT | NOCOUNT | NODES | NOEXPAND | NON_TRANSACTED_ACCESS | NORECOMPUTE | NORECOVERY | NOWAIT | NTILE | NUMANODE | NUMBER | NUMERIC_ROUNDABORT | OBJECT | OFFLINE | OFFSET | OLD_ACCOUNT | ONLINE | ONLY | OPEN_EXISTING | OPENJSON | OPTIMISTIC | OPTIMIZE | OUT | OUTPUT | OVERRIDE | OWNER | PAGE_VERIFY | PARAMETERIZATION | PARTITION | PARTITIONS | PARTNER | PATH | POISON_MESSAGE_HANDLING | POOL | PORT | PRECEDING | PRIMARY_ROLE | PRIOR | PRIORITY | PRIORITY_LEVEL | PRIVATE | PRIVATE_KEY | PRIVILEGES | PROCEDURE_NAME | PROPERTY | PROVIDER | PROVIDER_KEY_NAME | QUERY | QUEUE | QUEUE_DELAY | QUOTED_IDENTIFIER | RANGE | RANK | RC2 | RC4 | RC4_128 | READ_COMMITTED_SNAPSHOT | READ_ONLY | READ_ONLY_ROUTING_LIST | READ_WRITE | READONLY | REBUILD | RECEIVE | RECOMPILE | RECOVERY | RECURSIVE_TRIGGERS | RELATIVE | REMOTE | REMOTE_SERVICE_NAME | REMOVE | REORGANIZE | REPEATABLE | REPLICA | REQUEST_MAX_CPU_TIME_SEC | REQUEST_MAX_MEMORY_GRANT_PERCENT | REQUEST_MEMORY_GRANT_TIMEOUT_SEC | REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT | RESERVE_DISK_SPACE | RESOURCE | RESOURCE_MANAGER_LOCATION | RESTRICTED_USER | RETENTION | ROBUST | ROOT | ROUTE | ROW | ROW_NUMBER | ROWGUID | ROWS | SAMPLE | SCHEMABINDING | SCOPED | SCROLL | SCROLL_LOCKS | SEARCH | SECONDARY | SECONDARY_ONLY | SECONDARY_ROLE | SECONDS | SECRET | SECURITY | SECURITY_LOG | SEEDING_MODE | SELF | SEMI_SENSITIVE | SEND | SENT | SEQUENCE | SERIALIZABLE | SESSION_TIMEOUT | SETERROR | SHARE | SHOWPLAN | SIGNATURE | SIMPLE | SINGLE_USER | SIZE | SMALLINT | SNAPSHOT | SPATIAL_WINDOW_MAX_CELLS | STANDBY | START_DATE | STATIC | STATS_STREAM | STATUS | STATUSONLY | STDEV | STDEVP | STOPLIST | STRING_AGG | STUFF | SUBJECT | SUBSCRIPTION | SUM | SUSPEND | SYMMETRIC | SYNCHRONOUS_COMMIT | SYNONYM | SYSTEM | TAKE | TARGET_RECOVERY_TIME | TB | TEXTIMAGE_ON | THROW | TIES | TIME | TIMEOUT | TIMER | TINYINT | TORN_PAGE_DETECTION | TRANSFORM_NOISE_WORDS | TRIPLE_DES | TRIPLE_DES_3KEY | TRUSTWORTHY | TRY | TSQL | TWO_DIGIT_YEAR_CUTOFF | TYPE | TYPE_WARNING | UNBOUNDED | UNCOMMITTED | UNKNOWN | UNLIMITED | UOW | USING | VALID_XML | VALIDATION | VALUE | VAR | VARP | VIEW_METADATA | VIEWS | WAIT | WELL_FORMED_XML | WITHOUT_ARRAY_WRAPPER | WORK | WORKLOAD | XML | XMLDATA | XMLNAMESPACES | XMLSCHEMA | XSINIL | ABSENT | AES | ALLOW_CONNECTIONS | ALLOW_MULTIPLE_EVENT_LOSS | ALLOW_SINGLE_EVENT_LOSS | ANONYMOUS | APPEND | APPLICATION | ASYMMETRIC | ASYNCHRONOUS_COMMIT | AUTHENTICATION | AUTOMATED_BACKUP_PREFERENCE | AUTOMATIC | AVAILABILITY_MODE | BEFORE | BLOCK | BLOCKSIZE | BLOCKING_HIERARCHY | BUFFER | BUFFERCOUNT | CACHE | CALLED | CERTIFICATE | CHANGETABLE | CHANGES | CHECK_POLICY | CHECK_EXPIRATION | CLASSIFIER_FUNCTION | CLUSTER | COMPRESSION | CONFIGURATION | CONTAINMENT | CONTEXT | CONTINUE_AFTER_ERROR | CONTRACT | CONTRACT_NAME | CONVERSATION | COPY_ONLY | CUME_DIST | CYCLE | DATA_COMPRESSION | DATA_SOURCE | DATABASE_MIRRORING | DEFAULT_DATABASE | DEFAULT_SCHEMA | DIAGNOSTICS | DIFFERENTIAL | DTC_SUPPORT | ENABLED | ENDPOINT | ERROR | EVENT | EVENTDATA | EVENT_RETENTION_MODE | EXECUTABLE_FILE | EXPIREDATE | EXTENSION | EXTERNAL_ACCESS | FAILOVER | FAILURECONDITIONLEVEL | FAN_IN | FILE_SNAPSHOT | FILENAME | FORCESEEK | FORCE_SERVICE_ALLOW_DATA_LOSS | GET | GOVERNOR | HASHED | HEALTHCHECKTIMEOUT | IIF | IO | INCLUDE | INCREMENT | INFINITE | INIT | INSTEAD | ISNULL | KERBEROS | KEY_PATH | KEY_STORE_PROVIDER_NAME | LANGUAGE | LIBRARY | LIFETIME | LINUX | LISTENER_IP | LISTENER_PORT | LOCAL_SERVICE_NAME | LOG | MATCHED | MASTER | MAX_MEMORY | MAXTRANSFER | MAXVALUE | MAX_DISPATCH_LATENCY | MAX_EVENT_SIZE | MAX_SIZE | MAX_OUTSTANDING_IO_PER_VOLUME | MEDIADESCRIPTION | MEDIANAME | MEMBER | MEMORY_PARTITION_MODE | MESSAGE_FORWARDING | MESSAGE_FORWARD_SIZE | MINVALUE | MIRROR | MUST_CHANGE | NOFORMAT | NOINIT | NONE | NOREWIND | NOSKIP | NOUNLOAD | NO_CHECKSUM | NO_COMPRESSION | NO_EVENT_LOSS | NOTIFICATION | NTLM | OLD_PASSWORD | ON_FAILURE | PAGE | PARAM_NODE | PARTIAL | PASSWORD | PERMISSION_SET | PER_CPU | PER_DB | PER_NODE | PERCENTILE_CONT | PERCENTILE_DISC | PERCENT_RANK | PERSISTED | PLATFORM | POLICY | PREDICATE | PROCESS | PROFILE | PYTHON | R | READ_WRITE_FILEGROUPS | REGENERATE | RELATED_CONVERSATION | RELATED_CONVERSATION_GROUP | REQUIRED | RESET | RESTART | RESUME | RETAINDAYS | RETURNS | REWIND | ROLE | RSA_512 | RSA_1024 | RSA_2048 | RSA_3072 | RSA_4096 | SAFETY | SAFE | SCHEDULER | SCHEME | SERVER | SERVICE | SERVICE_BROKER | SERVICE_NAME | SESSION | SID | SKIP_KEYWORD | SOFTNUMA | SOURCE | SPECIFICATION | SPLIT | SQLDUMPERFLAGS | SQLDUMPERPATH | SQLDUMPERTIMEOUT | STATE | STATS | START | STARTED | STARTUP_STATE | STOP | STOPPED | STOP_ON_ERROR | SUPPORTED | TAPE | TARGET | TCP | TRACK_CAUSALITY | TRANSFER | TRY_CAST | UNCHECKED | UNLOCK | UNSAFE | URL | USED | VERBOSELOGGING | VISIBILITY | WINDOWS | WITHOUT | WITNESS | ZONE //Build-ins: | VARCHAR | NVARCHAR | BINARY_KEYWORD | VARBINARY_KEYWORD | PRECISION //For some reason this is possible to use as ID ; // https://msdn.microsoft.com/en-us/library/ms175874.aspx id : ID | DOUBLE_QUOTE_ID | SQUARE_BRACKET_ID | keyword ; simple_id : ID ; // https://msdn.microsoft.com/en-us/library/ms188074.aspx // Spaces are allowed for comparison operators. comparison_operator : '=' | '>' | '<' | '<' '=' | '>' '=' | '<' '>' | '!' '=' | '!' '>' | '!' '<' ; assignment_operator : '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '^=' | '|=' ; file_size : DECIMAL( KB | MB | GB | TB | '%' )? ;
137,629
ANTLR
.g4
3,822
29.89011
757
0.645182
christianhelle/sqlcequery
50
13
2
GPL-3.0
9/19/2024, 2:48:21 PM (Europe/Amsterdam)
true
true
false
false
1
TSqlLexerCore.g4
christianhelle_sqlcequery/Source/TSqlParser/TSqlLexerCore.g4
/* T-SQL (Transact-SQL, MSSQL) grammar. The MIT License (MIT). Copyright (c) 2017, Mark Adams ([email protected]) Copyright (c) 2015-2017, Ivan Kochurkin ([email protected]), Positive Technologies. Copyright (c) 2016, Scott Ure ([email protected]). Copyright (c) 2016, Rui Zhang ([email protected]). Copyright (c) 2016, Marcus Henriksson ([email protected]). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ lexer grammar TSqlLexerCore; // Basic keywords (from https://msdn.microsoft.com/en-us/library/ms189822.aspx) ADD: 'ADD'; ALL: 'ALL'; ALTER: 'ALTER'; AND: 'AND'; ANY: 'ANY'; AS: 'AS'; ASC: 'ASC'; AUTHORIZATION: 'AUTHORIZATION'; BACKSLASH: '\\'; BACKUP: 'BACKUP'; BEGIN: 'BEGIN'; BETWEEN: 'BETWEEN'; BREAK: 'BREAK'; BROWSE: 'BROWSE'; BULK: 'BULK'; BY: 'BY'; CASCADE: 'CASCADE'; CASE: 'CASE'; CHECK: 'CHECK'; CHECKPOINT: 'CHECKPOINT'; CLOSE: 'CLOSE'; CLUSTERED: 'CLUSTERED'; COALESCE: 'COALESCE'; COLLATE: 'COLLATE'; COLUMN: 'COLUMN'; COMMIT: 'COMMIT'; COMPUTE: 'COMPUTE'; CONSTRAINT: 'CONSTRAINT'; CONTAINS: 'CONTAINS'; CONTAINSTABLE: 'CONTAINSTABLE'; CONTINUE: 'CONTINUE'; CONVERT: 'TRY_'? 'CONVERT'; CREATE: 'CREATE'; CROSS: 'CROSS'; CURRENT: 'CURRENT'; CURRENT_DATE: 'CURRENT_DATE'; CURRENT_TIME: 'CURRENT_TIME'; CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP'; CURRENT_USER: 'CURRENT_USER'; CURSOR: 'CURSOR'; DATABASE: 'DATABASE'; DBCC: 'DBCC'; DEALLOCATE: 'DEALLOCATE'; DECLARE: 'DECLARE'; DEFAULT: 'DEFAULT'; DELETE: 'DELETE'; DENY: 'DENY'; DESC: 'DESC'; DISK: 'DISK'; DISTINCT: 'DISTINCT'; DISTRIBUTED: 'DISTRIBUTED'; DOUBLE: 'DOUBLE'; DOUBLE_BACK_SLASH: '\\\\'; DOUBLE_FORWARD_SLASH: '//'; DROP: 'DROP'; DUMP: 'DUMP'; ELSE: 'ELSE'; END: 'END'; ERRLVL: 'ERRLVL'; ESCAPE: 'ESCAPE'; EXCEPT: 'EXCEPT'; EXECUTE: 'EXEC' 'UTE'?; EXISTS: 'EXISTS'; EXIT: 'EXIT'; EXTERNAL: 'EXTERNAL'; FETCH: 'FETCH'; FILE: 'FILE'; FILLFACTOR: 'FILLFACTOR'; FOR: 'FOR'; FOREIGN: 'FOREIGN'; FREETEXT: 'FREETEXT'; FREETEXTTABLE: 'FREETEXTTABLE'; FROM: 'FROM'; FULL: 'FULL'; FUNCTION: 'FUNCTION'; GOTO: 'GOTO'; GRANT: 'GRANT'; GROUP: 'GROUP'; HAVING: 'HAVING'; HOLDLOCK: 'HOLDLOCK'; IDENTITY: 'IDENTITY'; IDENTITY_INSERT: 'IDENTITY_INSERT'; IDENTITYCOL: 'IDENTITYCOL'; IF: 'IF'; IN: 'IN'; INDEX: 'INDEX'; INNER: 'INNER'; INSERT: 'INSERT'; INTERSECT: 'INTERSECT'; INTO: 'INTO'; IS: 'IS'; JOIN: 'JOIN'; KEY: 'KEY'; KILL: 'KILL'; LEFT: 'LEFT'; LIKE: 'LIKE'; LINENO: 'LINENO'; LOAD: 'LOAD'; MERGE: 'MERGE'; NATIONAL: 'NATIONAL'; NEGOTIATE: 'NEGOTIATE'; NOCHECK: 'NOCHECK'; NONCLUSTERED: 'NONCLUSTERED'; NOT: 'NOT'; NULL: 'NULL'; NULLIF: 'NULLIF'; OF: 'OF'; OFF: 'OFF'; OFFSETS: 'OFFSETS'; ON: 'ON'; OPEN: 'OPEN'; OPENDATASOURCE: 'OPENDATASOURCE'; OPENQUERY: 'OPENQUERY'; OPENROWSET: 'OPENROWSET'; OPENJSON: 'OPENJSON'; OPENXML: 'OPENXML'; OPTION: 'OPTION'; OR: 'OR'; ORDER: 'ORDER'; OUTER: 'OUTER'; OVER: 'OVER'; PERCENT: 'PERCENT'; PIVOT: 'PIVOT'; PLAN: 'PLAN'; PRECISION: 'PRECISION'; PRIMARY: 'PRIMARY'; PRINT: 'PRINT'; PROC: 'PROC'; PROCEDURE: 'PROCEDURE'; PUBLIC: 'PUBLIC'; RAISERROR: 'RAISERROR'; RAW: 'RAW'; READ: 'READ'; READTEXT: 'READTEXT'; RECONFIGURE: 'RECONFIGURE'; REFERENCES: 'REFERENCES'; REPLICATION: 'REPLICATION'; RESTORE: 'RESTORE'; RESTRICT: 'RESTRICT'; RETURN: 'RETURN'; REVERT: 'REVERT'; REVOKE: 'REVOKE'; RIGHT: 'RIGHT'; ROLLBACK: 'ROLLBACK'; ROWCOUNT: 'ROWCOUNT'; ROWGUIDCOL: 'ROWGUIDCOL'; RULE: 'RULE'; SAVE: 'SAVE'; SCHEMA: 'SCHEMA'; SECURITYAUDIT: 'SECURITYAUDIT'; SELECT: 'SELECT'; SEMANTICKEYPHRASETABLE: 'SEMANTICKEYPHRASETABLE'; SEMANTICSIMILARITYDETAILSTABLE: 'SEMANTICSIMILARITYDETAILSTABLE'; SEMANTICSIMILARITYTABLE: 'SEMANTICSIMILARITYTABLE'; SESSION_USER: 'SESSION_USER'; SET: 'SET'; SETUSER: 'SETUSER'; SHUTDOWN: 'SHUTDOWN'; SOME: 'SOME'; STATISTICS: 'STATISTICS'; SYSTEM_USER: 'SYSTEM_USER'; TABLE: 'TABLE'; TABLESAMPLE: 'TABLESAMPLE'; TEXTSIZE: 'TEXTSIZE'; THEN: 'THEN'; TO: 'TO'; TOP: 'TOP'; TRAN: 'TRAN'; TRANSACTION: 'TRANSACTION'; TRIGGER: 'TRIGGER'; TRUNCATE: 'TRUNCATE'; TSEQUAL: 'TSEQUAL'; UNION: 'UNION'; UNIQUE: 'UNIQUE'; UNPIVOT: 'UNPIVOT'; UPDATE: 'UPDATE'; UPDATETEXT: 'UPDATETEXT'; USE: 'USE'; USER: 'USER'; VALUES: 'VALUES'; VARYING: 'VARYING'; VIEW: 'VIEW'; WAITFOR: 'WAITFOR'; WHEN: 'WHEN'; WHERE: 'WHERE'; WHILE: 'WHILE'; WITH: 'WITH'; WITHIN: 'WITHIN'; WRITETEXT: 'WRITETEXT'; //Keywords that can exist in ID etc ABSOLUTE: 'ABSOLUTE'; AT_KEYWORD: 'AT'; ACCENT_SENSITIVITY: 'ACCENT_SENSITIVITY'; ACTION: 'ACTION'; ACTIVATION: 'ACTIVATION'; ACTIVE: 'ACTIVE'; ADDRESS: 'ADDRESS'; AES_128: 'AES_128'; AES_192: 'AES_192'; AES_256: 'AES_256'; AFFINITY: 'AFFINITY'; AFTER: 'AFTER'; AGGREGATE: 'AGGREGATE'; ALGORITHM: 'ALGORITHM'; ALLOW_ENCRYPTED_VALUE_MODIFICATIONS: 'ALLOW_ENCRYPTED_VALUE_MODIFICATIONS'; ALLOW_SNAPSHOT_ISOLATION: 'ALLOW_SNAPSHOT_ISOLATION'; ALLOWED: 'ALLOWED'; ANSI_NULL_DEFAULT: 'ANSI_NULL_DEFAULT'; ANSI_NULLS: 'ANSI_NULLS'; ANSI_PADDING: 'ANSI_PADDING'; ANSI_WARNINGS: 'ANSI_WARNINGS'; APPLICATION_LOG: 'APPLICATION_LOG'; APPLY: 'APPLY'; ARITHABORT: 'ARITHABORT'; ASSEMBLY: 'ASSEMBLY'; AUDIT: 'AUDIT'; AUDIT_GUID: 'AUDIT_GUID'; AUTO: 'AUTO'; AUTO_CLEANUP: 'AUTO_CLEANUP'; AUTO_CLOSE: 'AUTO_CLOSE'; AUTO_CREATE_STATISTICS: 'AUTO_CREATE_STATISTICS'; AUTO_SHRINK: 'AUTO_SHRINK'; AUTO_UPDATE_STATISTICS: 'AUTO_UPDATE_STATISTICS'; AUTO_UPDATE_STATISTICS_ASYNC: 'AUTO_UPDATE_STATISTICS_ASYNC'; AVAILABILITY: 'AVAILABILITY'; AVG: 'AVG'; BACKUP_PRIORITY: 'BACKUP_PRIORITY'; BEGIN_DIALOG: 'BEGIN_DIALOG'; BIGINT: 'BIGINT'; BINARY_KEYWORD: 'BINARY'; BINARY_BASE64: 'BINARY BASE64'; BINARY_CHECKSUM: 'BINARY_CHECKSUM'; BINDING: 'BINDING'; BLOB_STORAGE: 'BLOB_STORAGE'; BROKER: 'BROKER'; BROKER_INSTANCE: 'BROKER_INSTANCE'; BULK_LOGGED: 'BULK_LOGGED'; CALLER: 'CALLER'; CAP_CPU_PERCENT: 'CAP_CPU_PERCENT'; CAST: 'CAST'; TRY_CAST: 'TRY_CAST'; CATALOG: 'CATALOG'; CATCH: 'CATCH'; CHANGE_RETENTION: 'CHANGE_RETENTION'; CHANGE_TRACKING: 'CHANGE_TRACKING'; CHECKSUM: 'CHECKSUM'; CHECKSUM_AGG: 'CHECKSUM_AGG'; CLEANUP: 'CLEANUP'; COLLECTION: 'COLLECTION'; COLUMN_MASTER_KEY: 'COLUMN_MASTER_KEY'; COMMITTED: 'COMMITTED'; COMPATIBILITY_LEVEL: 'COMPATIBILITY_LEVEL'; CONCAT: 'CONCAT'; CONCAT_NULL_YIELDS_NULL: 'CONCAT_NULL_YIELDS_NULL'; CONTENT: 'CONTENT'; CONTROL: 'CONTROL'; COOKIE: 'COOKIE'; COUNT: 'COUNT'; COUNT_BIG: 'COUNT_BIG'; COUNTER: 'COUNTER'; CPU: 'CPU'; CREATE_NEW: 'CREATE_NEW'; CREATION_DISPOSITION: 'CREATION_DISPOSITION'; CREDENTIAL: 'CREDENTIAL'; CRYPTOGRAPHIC: 'CRYPTOGRAPHIC'; CUME_DIST: 'CUME_DIST'; CURSOR_CLOSE_ON_COMMIT: 'CURSOR_CLOSE_ON_COMMIT'; CURSOR_DEFAULT: 'CURSOR_DEFAULT'; DATA: 'DATA'; DATE_CORRELATION_OPTIMIZATION: 'DATE_CORRELATION_OPTIMIZATION'; DATEADD: 'DATEADD'; DATEDIFF: 'DATEDIFF'; DATENAME: 'DATENAME'; DATEPART: 'DATEPART'; DAYS: 'DAYS'; DB_CHAINING: 'DB_CHAINING'; DB_FAILOVER: 'DB_FAILOVER'; DECRYPTION: 'DECRYPTION'; DEFAULT_DOUBLE_QUOTE: ["]'DEFAULT'["]; DEFAULT_FULLTEXT_LANGUAGE: 'DEFAULT_FULLTEXT_LANGUAGE'; DEFAULT_LANGUAGE: 'DEFAULT_LANGUAGE'; DELAY: 'DELAY'; DELAYED_DURABILITY: 'DELAYED_DURABILITY'; DELETED: 'DELETED'; DENSE_RANK: 'DENSE_RANK'; DEPENDENTS: 'DEPENDENTS'; DES: 'DES'; DESCRIPTION: 'DESCRIPTION'; DESX: 'DESX'; DHCP: 'DHCP'; DIALOG: 'DIALOG'; DIRECTORY_NAME: 'DIRECTORY_NAME'; DISABLE: 'DISABLE'; DISABLE_BROKER: 'DISABLE_BROKER'; DISABLED: 'DISABLED'; DISK_DRIVE: [A-Z][:]; DOCUMENT: 'DOCUMENT'; DYNAMIC: 'DYNAMIC'; ELEMENTS: 'ELEMENTS'; EMERGENCY: 'EMERGENCY'; EMPTY: 'EMPTY'; ENABLE: 'ENABLE'; ENABLE_BROKER: 'ENABLE_BROKER'; ENCRYPTED_VALUE: 'ENCRYPTED_VALUE'; ENCRYPTION: 'ENCRYPTION'; ENDPOINT_URL: 'ENDPOINT_URL'; ERROR_BROKER_CONVERSATIONS: 'ERROR_BROKER_CONVERSATIONS'; EXCLUSIVE: 'EXCLUSIVE'; EXECUTABLE: 'EXECUTABLE'; EXIST: 'EXIST'; EXPAND: 'EXPAND'; EXPIRY_DATE: 'EXPIRY_DATE'; EXPLICIT: 'EXPLICIT'; FAIL_OPERATION: 'FAIL_OPERATION'; FAILOVER_MODE: 'FAILOVER_MODE'; FAILURE: 'FAILURE'; FAILURE_CONDITION_LEVEL: 'FAILURE_CONDITION_LEVEL'; FAST: 'FAST'; FAST_FORWARD: 'FAST_FORWARD'; FILEGROUP: 'FILEGROUP'; FILEGROWTH: 'FILEGROWTH'; FILENAME: 'FILENAME'; FILEPATH: 'FILEPATH'; FILESTREAM: 'FILESTREAM'; FILTER: 'FILTER'; FIRST: 'FIRST'; FIRST_VALUE: 'FIRST_VALUE'; FOLLOWING: 'FOLLOWING'; FORCE: 'FORCE'; FORCE_FAILOVER_ALLOW_DATA_LOSS: 'FORCE_FAILOVER_ALLOW_DATA_LOSS'; FORCED: 'FORCED'; FORMAT: 'FORMAT'; FORWARD_ONLY: 'FORWARD_ONLY'; FULLSCAN: 'FULLSCAN'; FULLTEXT: 'FULLTEXT'; GB: 'GB'; GETDATE: 'GETDATE'; GETUTCDATE: 'GETUTCDATE'; GLOBAL: 'GLOBAL'; GO_BATCH: [\r\n]* [\t ]* 'GO'[\t\n\r ]; GO: 'GO'; GROUP_MAX_REQUESTS: 'GROUP_MAX_REQUESTS'; GROUPING: 'GROUPING'; GROUPING_ID: 'GROUPING_ID'; HADR: 'HADR'; HASH: 'HASH'; HEALTH_CHECK_TIMEOUT: 'HEALTH_CHECK_TIMEOUT'; HIGH: 'HIGH'; HONOR_BROKER_PRIORITY: 'HONOR_BROKER_PRIORITY'; HOURS: 'HOURS'; IDENTITY_VALUE: 'IDENTITY_VALUE'; IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX: 'IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX'; IMMEDIATE: 'IMMEDIATE'; IMPERSONATE: 'IMPERSONATE'; IMPORTANCE: 'IMPORTANCE'; INCLUDE_NULL_VALUES: 'INCLUDE_NULL_VALUES'; INCREMENTAL: 'INCREMENTAL'; INITIATOR: 'INITIATOR'; INPUT: 'INPUT'; INSENSITIVE: 'INSENSITIVE'; INSERTED: 'INSERTED'; INT: 'INT'; IP: 'IP'; ISOLATION: 'ISOLATION'; JOB: 'JOB'; JSON: 'JSON'; KB: 'KB'; KEEP: 'KEEP'; KEEPFIXED: 'KEEPFIXED'; KEY_SOURCE: 'KEY_SOURCE'; KEYS: 'KEYS'; KEYSET: 'KEYSET'; LAG: 'LAG'; LAST: 'LAST'; LAST_VALUE: 'LAST_VALUE'; LEAD: 'LEAD'; LEVEL: 'LEVEL'; LIST: 'LIST'; LISTENER: 'LISTENER'; LISTENER_URL: 'LISTENER_URL'; LOB_COMPACTION: 'LOB_COMPACTION'; LOCAL: 'LOCAL'; LOCATION: 'LOCATION'; LOCK: 'LOCK'; LOCK_ESCALATION: 'LOCK_ESCALATION'; LOGIN: 'LOGIN'; LOOP: 'LOOP'; LOW: 'LOW'; MANUAL: 'MANUAL'; MARK: 'MARK'; MATERIALIZED: 'MATERIALIZED'; MAX: 'MAX'; MAX_CPU_PERCENT: 'MAX_CPU_PERCENT'; MAX_DOP: 'MAX_DOP'; MAX_FILES: 'MAX_FILES'; MAX_IOPS_PER_VOLUME: 'MAX_IOPS_PER_VOLUME'; MAX_MEMORY_PERCENT: 'MAX_MEMORY_PERCENT'; MAX_PROCESSES: 'MAX_PROCESSES'; MAX_QUEUE_READERS: 'MAX_QUEUE_READERS'; MAX_ROLLOVER_FILES: 'MAX_ROLLOVER_FILES'; MAXDOP: 'MAXDOP'; MAXRECURSION: 'MAXRECURSION'; MAXSIZE: 'MAXSIZE'; MB: 'MB'; MEDIUM: 'MEDIUM'; MEMORY_OPTIMIZED_DATA: 'MEMORY_OPTIMIZED_DATA'; MESSAGE: 'MESSAGE'; MIN: 'MIN'; MIN_ACTIVE_ROWVERSION: 'MIN_ACTIVE_ROWVERSION'; MIN_CPU_PERCENT: 'MIN_CPU_PERCENT'; MIN_IOPS_PER_VOLUME: 'MIN_IOPS_PER_VOLUME'; MIN_MEMORY_PERCENT: 'MIN_MEMORY_PERCENT'; MINUTES: 'MINUTES'; MIRROR_ADDRESS: 'MIRROR_ADDRESS'; MIXED_PAGE_ALLOCATION: 'MIXED_PAGE_ALLOCATION'; MODE: 'MODE'; MODIFY: 'MODIFY'; MOVE: 'MOVE'; MULTI_USER: 'MULTI_USER'; NAME: 'NAME'; NESTED_TRIGGERS: 'NESTED_TRIGGERS'; NEW_ACCOUNT: 'NEW_ACCOUNT'; NEW_BROKER: 'NEW_BROKER'; NEW_PASSWORD: 'NEW_PASSWORD'; NEXT: 'NEXT'; NO: 'NO'; NO_TRUNCATE: 'NO_TRUNCATE'; NO_WAIT: 'NO_WAIT'; NOCOUNT: 'NOCOUNT'; NODES: 'NODES'; NOEXPAND: 'NOEXPAND'; NON_TRANSACTED_ACCESS: 'NON_TRANSACTED_ACCESS'; NORECOMPUTE: 'NORECOMPUTE'; NORECOVERY: 'NORECOVERY'; NOWAIT: 'NOWAIT'; NTILE: 'NTILE'; NUMANODE: 'NUMANODE'; NUMBER: 'NUMBER'; NUMERIC_ROUNDABORT: 'NUMERIC_ROUNDABORT'; OBJECT: 'OBJECT'; OFFLINE: 'OFFLINE'; OFFSET: 'OFFSET'; OLD_ACCOUNT: 'OLD_ACCOUNT'; ONLINE: 'ONLINE'; ONLY: 'ONLY'; OPEN_EXISTING: 'OPEN_EXISTING'; OPTIMISTIC: 'OPTIMISTIC'; OPTIMIZE: 'OPTIMIZE'; OUT: 'OUT'; OUTPUT: 'OUTPUT'; OVERRIDE: 'OVERRIDE'; OWNER: 'OWNER'; PAGE_VERIFY: 'PAGE_VERIFY'; PARAMETERIZATION: 'PARAMETERIZATION'; PARTITION: 'PARTITION'; PARTITIONS: 'PARTITIONS'; PARTNER: 'PARTNER'; PATH: 'PATH'; PERCENT_RANK: 'PERCENT_RANK'; PERCENTILE_CONT: 'PERCENTILE_CONT'; PERCENTILE_DISC: 'PERCENTILE_DISC'; POISON_MESSAGE_HANDLING: 'POISON_MESSAGE_HANDLING'; POOL: 'POOL'; PORT: 'PORT'; PRECEDING: 'PRECEDING'; PRIMARY_ROLE: 'PRIMARY_ROLE'; PRIOR: 'PRIOR'; PRIORITY: 'PRIORITY'; PRIORITY_LEVEL: 'PRIORITY_LEVEL'; PRIVATE: 'PRIVATE'; PRIVATE_KEY: 'PRIVATE_KEY'; PRIVILEGES: 'PRIVILEGES'; PROCEDURE_NAME: 'PROCEDURE_NAME'; PROPERTY: 'PROPERTY'; PROVIDER: 'PROVIDER'; PROVIDER_KEY_NAME: 'PROVIDER_KEY_NAME'; QUERY: 'QUERY'; QUEUE: 'QUEUE'; QUEUE_DELAY: 'QUEUE_DELAY'; QUOTED_IDENTIFIER: 'QUOTED_IDENTIFIER'; RANGE: 'RANGE'; RANK: 'RANK'; RC2: 'RC2'; RC4: 'RC4'; RC4_128: 'RC4_128'; READ_COMMITTED_SNAPSHOT: 'READ_COMMITTED_SNAPSHOT'; READ_ONLY: 'READ_ONLY'; READ_ONLY_ROUTING_LIST: 'READ_ONLY_ROUTING_LIST'; READ_WRITE: 'READ_WRITE'; READONLY: 'READONLY'; REBUILD: 'REBUILD'; RECEIVE: 'RECEIVE'; RECOMPILE: 'RECOMPILE'; RECOVERY: 'RECOVERY'; RECURSIVE_TRIGGERS: 'RECURSIVE_TRIGGERS'; RELATIVE: 'RELATIVE'; REMOTE: 'REMOTE'; REMOTE_SERVICE_NAME: 'REMOTE_SERVICE_NAME'; REMOVE: 'REMOVE'; REORGANIZE: 'REORGANIZE'; REPEATABLE: 'REPEATABLE'; REPLICA: 'REPLICA'; REQUEST_MAX_CPU_TIME_SEC: 'REQUEST_MAX_CPU_TIME_SEC'; REQUEST_MAX_MEMORY_GRANT_PERCENT: 'REQUEST_MAX_MEMORY_GRANT_PERCENT'; REQUEST_MEMORY_GRANT_TIMEOUT_SEC: 'REQUEST_MEMORY_GRANT_TIMEOUT_SEC'; REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT: 'REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT'; RESERVE_DISK_SPACE: 'RESERVE_DISK_SPACE'; RESOURCE: 'RESOURCE'; RESOURCE_MANAGER_LOCATION: 'RESOURCE_MANAGER_LOCATION'; RESTRICTED_USER: 'RESTRICTED_USER'; RETENTION: 'RETENTION'; ROBUST: 'ROBUST'; ROOT: 'ROOT'; ROUTE: 'ROUTE'; ROW: 'ROW'; ROW_NUMBER: 'ROW_NUMBER'; ROWGUID: 'ROWGUID'; ROWS: 'ROWS'; SAMPLE: 'SAMPLE'; SCHEMABINDING: 'SCHEMABINDING'; SCOPED: 'SCOPED'; SCROLL: 'SCROLL'; SCROLL_LOCKS: 'SCROLL_LOCKS'; SEARCH: 'SEARCH'; SECONDARY: 'SECONDARY'; SECONDARY_ONLY: 'SECONDARY_ONLY'; SECONDARY_ROLE: 'SECONDARY_ROLE'; SECONDS: 'SECONDS'; SECRET: 'SECRET'; SECURITY: 'SECURITY'; SECURITY_LOG: 'SECURITY_LOG'; SEEDING_MODE: 'SEEDING_MODE'; SELF: 'SELF'; SEMI_SENSITIVE: 'SEMI_SENSITIVE'; SEND: 'SEND'; SENT: 'SENT'; SEQUENCE: 'SEQUENCE'; SERIALIZABLE: 'SERIALIZABLE'; SESSION_TIMEOUT: 'SESSION_TIMEOUT'; SETERROR: 'SETERROR'; SHARE: 'SHARE'; SHOWPLAN: 'SHOWPLAN'; SIGNATURE: 'SIGNATURE'; SIMPLE: 'SIMPLE'; SINGLE_USER: 'SINGLE_USER'; SIZE: 'SIZE'; SMALLINT: 'SMALLINT'; SNAPSHOT: 'SNAPSHOT'; SPATIAL_WINDOW_MAX_CELLS: 'SPATIAL_WINDOW_MAX_CELLS'; STANDBY: 'STANDBY'; START_DATE: 'START_DATE'; STATIC: 'STATIC'; STATS_STREAM: 'STATS_STREAM'; STATUS: 'STATUS'; STATUSONLY: 'STATUSONLY'; STDEV: 'STDEV'; STDEVP: 'STDEVP'; STOPLIST: 'STOPLIST'; STRING_AGG: 'STRING_AGG'; STUFF: 'STUFF'; SUBJECT: 'SUBJECT'; SUBSCRIPTION: 'SUBSCRIPTION'; SUM: 'SUM'; SUSPEND: 'SUSPEND'; SYMMETRIC: 'SYMMETRIC'; SYNCHRONOUS_COMMIT: 'SYNCHRONOUS_COMMIT'; SYNONYM: 'SYNONYM'; SYSTEM: 'SYSTEM'; TAKE: 'TAKE'; TARGET_RECOVERY_TIME: 'TARGET_RECOVERY_TIME'; TB: 'TB'; TEXTIMAGE_ON: 'TEXTIMAGE_ON'; THROW: 'THROW'; TIES: 'TIES'; TIME: 'TIME'; TIMEOUT: 'TIMEOUT'; TIMER: 'TIMER'; TINYINT: 'TINYINT'; TORN_PAGE_DETECTION: 'TORN_PAGE_DETECTION'; TRANSFORM_NOISE_WORDS: 'TRANSFORM_NOISE_WORDS'; TRIPLE_DES: 'TRIPLE_DES'; TRIPLE_DES_3KEY: 'TRIPLE_DES_3KEY'; TRUSTWORTHY: 'TRUSTWORTHY'; TRY: 'TRY'; TSQL: 'TSQL'; TWO_DIGIT_YEAR_CUTOFF: 'TWO_DIGIT_YEAR_CUTOFF'; TYPE: 'TYPE'; TYPE_WARNING: 'TYPE_WARNING'; UNBOUNDED: 'UNBOUNDED'; UNCOMMITTED: 'UNCOMMITTED'; UNKNOWN: 'UNKNOWN'; UNLIMITED: 'UNLIMITED'; UOW: 'UOW'; USING: 'USING'; VALID_XML: 'VALID_XML'; VALIDATION: 'VALIDATION'; VALUE: 'VALUE'; VAR: 'VAR'; VARBINARY_KEYWORD: 'VARBINARY'; VARP: 'VARP'; VIEW_METADATA: 'VIEW_METADATA'; VIEWS: 'VIEWS'; WAIT: 'WAIT'; WELL_FORMED_XML: 'WELL_FORMED_XML'; WITHOUT_ARRAY_WRAPPER: 'WITHOUT_ARRAY_WRAPPER'; WORK: 'WORK'; WORKLOAD: 'WORKLOAD'; XML: 'XML'; XMLDATA: 'XMLDATA'; XMLNAMESPACES: 'XMLNAMESPACES'; XMLSCHEMA: 'XMLSCHEMA'; XSINIL: 'XSINIL'; ZONE: 'ZONE'; DOLLAR_ACTION: '$ACTION'; //More keywords ABSENT: 'ABSENT'; AES: 'AES'; ALLOW_CONNECTIONS: 'ALLOW_CONNECTIONS'; ALLOW_MULTIPLE_EVENT_LOSS: 'ALLOW_MULTIPLE_EVENT_LOSS'; ALLOW_SINGLE_EVENT_LOSS: 'ALLOW_SINGLE_EVENT_LOSS'; ANONYMOUS: 'ANONYMOUS'; APPEND: 'APPEND'; APPLICATION: 'APPLICATION'; ASYMMETRIC: 'ASYMMETRIC'; ASYNCHRONOUS_COMMIT: 'ASYNCHRONOUS_COMMIT'; AUTHENTICATION: 'AUTHENTICATION'; AUTOMATED_BACKUP_PREFERENCE: 'AUTOMATED_BACKUP_PREFERENCE'; AUTOMATIC: 'AUTOMATIC'; AVAILABILITY_MODE: 'AVAILABILITY_MODE'; BEFORE: 'BEFORE'; BLOCK: 'BLOCK'; BLOCKSIZE: 'BLOCKSIZE'; BLOCKING_HIERARCHY: 'BLOCKING_HIERARCHY'; BUFFER: 'BUFFER'; BUFFERCOUNT: 'BUFFERCOUNT'; CACHE: 'CACHE'; CALLED: 'CALLED'; CERTIFICATE: 'CERTIFICATE'; CHANGETABLE: 'CHANGETABLE'; CHANGES: 'CHANGES'; CHECK_POLICY: 'CHECK_POLICY'; CHECK_EXPIRATION: 'CHECK_EXPIRATION'; CLASSIFIER_FUNCTION: 'CLASSIFIER_FUNCTION'; CLUSTER: 'CLUSTER'; COMPRESSION: 'COMPRESSION'; CONFIGURATION: 'CONFIGURATION'; CONTAINMENT: 'CONTAINMENT'; CONTEXT: 'CONTEXT'; CONTINUE_AFTER_ERROR: 'CONTINUE_AFTER_ERROR'; CONTRACT: 'CONTRACT'; CONTRACT_NAME: 'CONTRACT_NAME'; CONVERSATION: 'CONVERSATION'; COPY_ONLY: 'COPY_ONLY'; CYCLE: 'CYCLE'; DATA_COMPRESSION: 'DATA_COMPRESSION'; DATA_SOURCE: 'DATA_SOURCE'; DATABASE_MIRRORING: 'DATABASE_MIRRORING'; DEFAULT_DATABASE: 'DEFAULT_DATABASE'; DEFAULT_SCHEMA: 'DEFAULT_SCHEMA'; DIAGNOSTICS: 'DIAGNOSTICS'; DIFFERENTIAL: 'DIFFERENTIAL'; DTC_SUPPORT: 'DTC_SUPPORT'; ENABLED: 'ENABLED'; ENDPOINT: 'ENDPOINT'; ERROR: 'ERROR'; EVENT: 'EVENT'; EVENTDATA: 'EVENTDATA' '(' ')'; EVENT_RETENTION_MODE: 'EVENT_RETENTION_MODE'; EXECUTABLE_FILE: 'EXECUTABLE_FILE'; EXPIREDATE: 'EXPIREDATE'; EXTENSION: 'EXTENSION'; EXTERNAL_ACCESS: 'EXTERNAL_ACCESS'; FAILOVER: 'FAILOVER'; FAILURECONDITIONLEVEL: 'FAILURECONDITIONLEVEL'; FAN_IN: 'FAN_IN'; FILE_SNAPSHOT: 'FILE_SNAPSHOT'; FORCESEEK: 'FORCESEEK'; FORCE_SERVICE_ALLOW_DATA_LOSS: 'FORCE_SERVICE_ALLOW_DATA_LOSS'; GET: 'GET'; GOVERNOR: 'GOVERNOR'; HASHED: 'HASHED'; HEALTHCHECKTIMEOUT: 'HEALTHCHECKTIMEOUT'; IIF: 'IIF'; IO: 'IO'; INCLUDE: 'INCLUDE'; INCREMENT: 'INCREMENT'; INFINITE: 'INFINITE'; INIT: 'INIT'; INSTEAD: 'INSTEAD'; ISNULL: 'ISNULL'; KERBEROS: 'KERBEROS'; KEY_PATH: 'KEY_PATH'; KEY_STORE_PROVIDER_NAME: 'KEY_STORE_PROVIDER_NAME'; LANGUAGE: 'LANGUAGE'; LIBRARY: 'LIBRARY'; LIFETIME: 'LIFETIME'; LINUX: 'LINUX'; LISTENER_IP: 'LISTENER_IP'; LISTENER_PORT: 'LISTENER_PORT'; LOCAL_SERVICE_NAME: 'LOCAL_SERVICE_NAME'; LOG: 'LOG'; MATCHED: 'MATCHED'; MASTER: 'MASTER'; MAX_MEMORY: 'MAX_MEMORY'; MAXTRANSFER: 'MAXTRANSFER'; MAXVALUE: 'MAXVALUE'; MAX_DISPATCH_LATENCY: 'MAX_DISPATCH_LATENCY'; MAX_EVENT_SIZE: 'MAX_EVENT_SIZE'; MAX_SIZE: 'MAX_SIZE'; MAX_OUTSTANDING_IO_PER_VOLUME: 'MAX_OUTSTANDING_IO_PER_VOLUME'; MEDIADESCRIPTION: 'MEDIADESCRIPTION'; MEDIANAME: 'MEDIANAME'; MEMBER: 'MEMBER'; MEMORY_PARTITION_MODE: 'MEMORY_PARTITION_MODE'; MESSAGE_FORWARDING: 'MESSAGE_FORWARDING'; MESSAGE_FORWARD_SIZE: 'MESSAGE_FORWARD_SIZE'; MINVALUE: 'MINVALUE'; MIRROR: 'MIRROR'; MUST_CHANGE: 'MUST_CHANGE'; NOFORMAT: 'NOFORMAT'; NOINIT: 'NOINIT'; NONE: 'NONE'; NOREWIND: 'NOREWIND'; NOSKIP: 'NOSKIP'; NOUNLOAD: 'NOUNLOAD'; NO_CHECKSUM: 'NO_CHECKSUM'; NO_COMPRESSION: 'NO_COMPRESSION'; NO_EVENT_LOSS: 'NO_EVENT_LOSS'; NOTIFICATION: 'NOTIFICATION'; NTLM: 'NTLM'; OLD_PASSWORD: 'OLD_PASSWORD'; ON_FAILURE: 'ON_FAILURE'; PAGE: 'PAGE'; PARAM_NODE: 'PARAM_NODE'; PARTIAL: 'PARTIAL'; PASSWORD: 'PASSWORD'; PERMISSION_SET: 'PERMISSION_SET'; PER_CPU: 'PER_CPU'; PER_DB: 'PER_DB'; PER_NODE: 'PER_NODE'; PERSISTED: 'PERSISTED'; PLATFORM: 'PLATFORM'; POLICY: 'POLICY'; PREDICATE: 'PREDICATE'; PROCESS: 'PROCESS'; PROFILE: 'PROFILE'; PYTHON: 'PYTHON'; R: 'R'; READ_WRITE_FILEGROUPS: 'READ_WRITE_FILEGROUPS'; REGENERATE: 'REGENERATE'; RELATED_CONVERSATION: 'RELATED_CONVERSATION'; RELATED_CONVERSATION_GROUP: 'RELATED_CONVERSATION_GROUP'; REQUIRED: 'REQUIRED'; RESET: 'RESET'; RESTART: 'RESTART'; RESUME: 'RESUME'; RETAINDAYS: 'RETAINDAYS'; RETURNS: 'RETURNS'; REWIND: 'REWIND'; ROLE: 'ROLE'; RSA_512: 'RSA_512'; RSA_1024: 'RSA_1024'; RSA_2048: 'RSA_2048'; RSA_3072: 'RSA_3072'; RSA_4096: 'RSA_4096'; SAFETY: 'SAFETY'; SAFE: 'SAFE'; SCHEDULER: 'SCHEDULER'; SCHEME: 'SCHEME'; SERVER: 'SERVER'; SERVICE: 'SERVICE'; SERVICE_BROKER: 'SERVICE_BROKER'; SERVICE_NAME: 'SERVICE_NAME'; SESSION: 'SESSION'; SHRINKLOG: 'SHRINKLOG'; SID: 'SID'; SKIP_KEYWORD: 'SKIP'; SOFTNUMA: 'SOFTNUMA'; SOURCE: 'SOURCE'; SPECIFICATION: 'SPECIFICATION'; SPLIT: 'SPLIT'; SQLDUMPERFLAGS: 'SQLDUMPERFLAGS'; SQLDUMPERPATH: 'SQLDUMPERPATH'; SQLDUMPERTIMEOUT: 'SQLDUMPERTIMEOUTS'; STATE: 'STATE'; STATS: 'STATS'; START: 'START'; STARTED: 'STARTED'; STARTUP_STATE: 'STARTUP_STATE'; STOP: 'STOP'; STOPPED: 'STOPPED'; STOP_ON_ERROR: 'STOP_ON_ERROR'; SUPPORTED: 'SUPPORTED'; TAPE: 'TAPE'; TARGET: 'TARGET'; TCP: 'TCP'; TRACK_CAUSALITY: 'TRACK_CAUSALITY'; TRANSFER: 'TRANSFER'; UNCHECKED: 'UNCHECKED'; UNLOCK: 'UNLOCK'; UNSAFE: 'UNSAFE'; URL: 'URL'; USED: 'USED'; VERBOSELOGGING: 'VERBOSELOGGING'; VISIBILITY: 'VISIBILITY'; WINDOWS: 'WINDOWS'; WITHOUT: 'WITHOUT'; WITNESS: 'WITNESS'; //Build-ins: VARCHAR: 'VARCHAR'; NVARCHAR: 'NVARCHAR'; SPACE: [ \t\r\n]+ -> skip; // https://docs.microsoft.com/en-us/sql/t-sql/language-elements/slash-star-comment-transact-sql COMMENT: '/*' (COMMENT | .)*? '*/' -> channel(HIDDEN); LINE_COMMENT: '--' ~[\r\n]* -> channel(HIDDEN); // TODO: ID can be not only Latin. DOUBLE_QUOTE_ID: '"' ~'"'+ '"'; SINGLE_QUOTE: '\''; SQUARE_BRACKET_ID: '[' (~']' | ']' ']')* ']'; LOCAL_ID: '@' ([A-Z_$@#0-9] | FullWidthLetter)*; DECIMAL: DEC_DIGIT+; ID: ( [A-Z_#] | FullWidthLetter) ( [A-Z_#$@0-9] | FullWidthLetter )*; STRING: 'N'? '\'' (~'\'' | '\'\'')* '\''; BINARY: '0' 'X' HEX_DIGIT*; FLOAT: DEC_DOT_DEC; REAL: (DECIMAL | DEC_DOT_DEC) ('E' [+-]? DEC_DIGIT+); EQUAL: '='; GREATER: '>'; LESS: '<'; EXCLAMATION: '!'; PLUS_ASSIGN: '+='; MINUS_ASSIGN: '-='; MULT_ASSIGN: '*='; DIV_ASSIGN: '/='; MOD_ASSIGN: '%='; AND_ASSIGN: '&='; XOR_ASSIGN: '^='; OR_ASSIGN: '|='; DOUBLE_BAR: '||'; DOT: '.'; UNDERLINE: '_'; AT: '@'; SHARP: '#'; DOLLAR: '$'; LR_BRACKET: '('; RR_BRACKET: ')'; COMMA: ','; SEMI: ';'; COLON: ':'; STAR: '*'; DIVIDE: '/'; MODULE: '%'; PLUS: '+'; MINUS: '-'; BIT_NOT: '~'; BIT_OR: '|'; BIT_AND: '&'; BIT_XOR: '^'; fragment LETTER: [A-Z_]; fragment DEC_DOT_DEC: (DEC_DIGIT+ '.' DEC_DIGIT+ | DEC_DIGIT+ '.' | '.' DEC_DIGIT+); fragment HEX_DIGIT: [0-9A-F]; fragment DEC_DIGIT: [0-9]; fragment FullWidthLetter : '\u00c0'..'\u00d6' | '\u00d8'..'\u00f6' | '\u00f8'..'\u00ff' | '\u0100'..'\u1fff' | '\u2c00'..'\u2fff' | '\u3040'..'\u318f' | '\u3300'..'\u337f' | '\u3400'..'\u3fff' | '\u4e00'..'\u9fff' | '\ua000'..'\ud7ff' | '\uf900'..'\ufaff' | '\uff00'..'\ufff0' // | '\u10000'..'\u1F9FF' //not support four bytes chars // | '\u20000'..'\u2FA1F' ;
45,942
ANTLR
.g4
904
49.738938
95
0.359941
christianhelle/sqlcequery
50
13
2
GPL-3.0
9/19/2024, 2:48:21 PM (Europe/Amsterdam)
true
true
false
false
2
UnicodeClasses.g4
xcporter_MetaView/src/main/antlr/UnicodeClasses.g4
"/**\n * Kotlin lexical grammar in ANTLR4 notation (Unicode classes)\n *\n * Taken from http://www.a(...TRUNCATED)
23,131
ANTLR
.g4
1,641
12.096892
74
0.466369
xcporter/MetaView
24
1
2
GPL-3.0
9/19/2024, 2:48:29 PM (Europe/Amsterdam)
true
true
true
true
3
KotlinLexer.g4
xcporter_MetaView/src/main/antlr/KotlinLexer.g4
"/**\n * Kotlin lexical grammar in ANTLR4 notation\n */\n\nlexer grammar KotlinLexer;\n\nimport Unic(...TRUNCATED)
12,067
ANTLR
.g4
453
24.328918
98
0.679574
xcporter/MetaView
24
1
2
GPL-3.0
9/19/2024, 2:48:29 PM (Europe/Amsterdam)
true
true
true
true
4
KotlinParser.g4
xcporter_MetaView/src/main/antlr/KotlinParser.g4
"/**\n * Kotlin syntax grammar in ANTLR4 notation\n */\n\nparser grammar KotlinParser;\n\noptions { (...TRUNCATED)
17,095
ANTLR
.g4
741
18.82861
134
0.703154
xcporter/MetaView
24
1
2
GPL-3.0
9/19/2024, 2:48:29 PM (Europe/Amsterdam)
true
true
true
true
5
plsql.g4
datacamp_antlr-plsql/antlr_plsql/plsql.g4
"/**\n * Oracle(c) PL/SQL 11g Parser\n *\n * Copyright (c) 2009-2011 Alexandre Porcelli <alexandre.p(...TRUNCATED)
121,455
ANTLR
.g4
3,969
26.480474
198
0.548978
datacamp/antlr-plsql
17
14
6
AGPL-3.0
9/19/2024, 2:48:36 PM (Europe/Amsterdam)
true
true
false
false
6
Delphi.g4
gotthardsen_Delphi-ANTRL4-Grammar/Delphi.g4
"grammar Delphi;\n\n/*\n * Sonar Delphi Plugin\n * Copyright (C) 2010 SonarSource\n * [email protected](...TRUNCATED)
42,720
ANTLR
.g4
890
32.516854
204
0.367812
gotthardsen/Delphi-ANTRL4-Grammar
15
7
3
LGPL-3.0
9/19/2024, 2:48:36 PM (Europe/Amsterdam)
true
false
false
true
7
MurphySDR-In3_Cu.g4
MillePoels_MurPhySDR/hardware/gerber-files/MurphySDR-In3_Cu.g4
"%TF.GenerationSoftware,KiCad,Pcbnew,8.0.1*%\n%TF.CreationDate,2024-04-14T19:48:42+02:00*%\n%TF.Proj(...TRUNCATED)
368,403
ANTLR
.g4
14,526
24.361627
65
0.91815
MillePoels/MurPhySDR
13
1
1
GPL-3.0
9/19/2024, 2:48:36 PM (Europe/Amsterdam)
false
false
false
false
8
Java.g4
le-moulin-studio_java-semantic-diff/src/main/antlr4/Java.g4
"/*\n [The \"BSD licence\"]\n Copyright (c) 2013 Terence Parr, Sam Harwell\n All rights reserved.\n\(...TRUNCATED)
20,992
ANTLR
.g4
842
21.119952
107
0.623466
le-moulin-studio/java-semantic-diff
12
1
3
AGPL-3.0
9/19/2024, 2:48:36 PM (Europe/Amsterdam)
true
true
true
true
9
UVLJava.g4
Universal-Variability-Language_uvl-parser/uvl/UVLJava.g4
"grammar UVLJava;\nimport UVLBase;\n@header {\npackage uvl;\n}\n@lexer::members {\n // A queue wher(...TRUNCATED)
4,403
ANTLR
.g4
126
29.52381
99
0.615258
Universal-Variability-Language/uvl-parser
10
8
8
LGPL-3.0
9/19/2024, 2:48:36 PM (Europe/Amsterdam)
true
true
false
false

The Heap Dataset

We develop The Heap, a new contamination-free multilingual code dataset comprising 57 languages, which facilitates LLM evaluation reproducibility. The reproduction packge can be found here.

Is your code in The Heap?

If you would like to have your data removed from the dataset, follow the instructions on GitHub.

Usage

Using the Datasets API, our dataset can be used as follows:

from datasets import load_dataset

dataset_name = 'redpajama'
language = 'Python'

ds = load_dataset(
    "AISE-TUDelft/the-heap",
    f"{language}",
    split="train",
    num_proc=16
)

ds = ds.filter(lambda x: not x[f'exact_duplicates_{dataset_name}'] and not x[f'near_duplicates_{dataset_name}'])

Collection

We collect up to 50,000 public repositories using the GitHub API, focusing on license type, star count, and creation date. Repositories with non-permissive licenses are prioritized to reduce contamination, as public code datasets we deduplicate against primarily focus on permissive or no-license repositories. We select repositories created before August 2024 in decreasing order of their star counts. To handle GitHub rate limits, we use timeouts and pagination during the scraping process.

Copyleft licenses included in the The Heap

License Family
CECILL-1.0, CECILL-1.1, CECILL-2.0,
CECILL-2.1, CECILL-C, EPL-1.0, EPL-2.0,
LGPL-2.1, LGPL-3.0, MS-RL, MPL-2.0
Weak Copyleft
GPL-2.0, GPL-3.0 Strong Copyleft
AGPL-3.0, EUPL-1.1, EUPL-1.2, OSL-3.0 Network Copyleft

The features we extract for each repository are illustrated in the example below.

  {
    "id": 126178683,
    "full_name": "halo-dev/halo",
    "html_url": "https://github.com/halo-dev/halo",
    "stargazers_count": 29115,
    "forks_count": 8985,
    "watchers_count": 29115,
    "open_issues_count": 278,
    "language": "Java",
    "created_at": "2018-03-21T12:56:52Z",
    "pushed_at": "2023-10-28T16:29:39Z",
    "license": {
      "key": "gpl-3.0",
      "name": "GNU General Public License v3.0",
      "spdx_id": "GPL-3.0",
      "url": "https://api.github.com/licenses/gpl-3.0",
      "node_id": "MDc6TGljZW5zZTk="
    },
    "retrieval_date": "10/30/2023, 3:24:57 PM (Europe/Amsterdam)"
  }

Repository Fields

  • id: unique id of the repo
  • full_name: complete name of the repo
  • html_url: URL to the repo
  • stargazers_count: number of stars of the repo
  • forks_count: number of forks of the repo
  • watchers_count: number of watchers of the repo
  • open_issues_count: number of open issues of the repo at the extraction time
  • language: main language of the repo
  • created_at: creation date of the repo
  • pushed_at: date of the most recent push to the repo until the extraction date
  • license: license type of the repo
  • retrieval_date: date when the repo was scraped from GitHub

We start by retrieving repositories with more than 900 stars using two-month tumbling windows. If we hit the 1000 repository limit per window (for a personal GitHub account), we shorten the search space to a one-month window and restart the iteration. Otherwise, the window advances by two months. Once the entire timeframe (until August 2024) is covered, we reduce the star search space: between 900 and 100 stars, we decrease the interval by 50 (e.g. search between [900, 850]), between 100 and 10 stars, we decrease the interval by 10, and for the last 10 stars, we decrease by 1. Since most repositories fall within the 0-100 star range (e.g. Figure 1 showcases the distribution of repositories with up to 500 stars for Java), using the creation date and star count filters helps us avoid API limits and scrape more data by narrowing the search space. The creation date window can be reduced even further (week or day level), in order to extract more data. We remove any potential duplicated repositories obtained due to the pagination process. Lastly, we extract all the files corresponding to each language. We extend the programming languages extension list used for The Stack with 4 languages: EJS, Raku, Starlark, and WebAssembly.

Figure 1: Distribution of scraped repositories with at most 500 stars.

Figure 1: Distribution of scraped repositories with at most 500 stars for Java

Cleaning

The next stage in our dataset pipeline is the cleaning procedure. We exclude any files larger than 10 MB and those with fewer than 10 words.

Deduplication

The final stage of our dataset pipeline is the deduplication process. We apply both exact and near deduplication against open code datasets listed in the table below.

Open code datasets used for deduplication

Dataset Source
The Stack V2 All permissively licensed and unlicensed files collected in the Software Heritage archive.
The Stack All permissively licensed repositories collected in the GHArchive and scraped from GitHub.
Red Pajama Repositories from the GitHub dataset hosted by Google BigQuery licensed under MIT, BSD, or Apache licenses.
GitHub Code Repositories from the GitHub dataset hosted by Google BigQuery.
CodeParrot All Python files from the GitHub dataset hosted by Google BigQuery.

Exact Deduplication

We remove exact duplicates within our dataset itself, and then we apply exact deduplication against the open datasets. For that, we use the sha256 function to generate hashes for each file. We choose this hash function because it provides a uniform distribution of hash values, minimizes collisions, and ensures even distribution across the hash space.

Near Deduplication

We apply the MinHashLSH algorithm using the datasketch1 library. To calculate the minhashes, we use the same hash function as above, but we extract the first 16 bytes to generate 128-bit hash values. This approach balances the need for a strong hash function with the efficiency of a shorter hash length.

Additionally, we use 128 file permutations for LSH, with weights of 0.4 for precision and 0.6 for recall. We generate 7-character shingles after lowercasing the file content and removing whitespace. We find that 7-shingles provide a reasonable trade-off between the number of shingles and the data processed, being small enough to keep the number of unique shingles manageable yet large enough to provide meaningful comparisons. It was shown that the number of shingles should be large enough to ensure a low probability of shingles appearing across documents, with k = 5 suggested for smaller documents such as emails. However, code files usually contain a larger dictionary of characters than emails, including arithmetic and comparison operators which are less frequent in emails. Thus, given the increased complexity and size of code files, we consider 7-shingles to be appropriate to capture sufficient context, ensuring uniqueness and reducing false positives, which smaller shingles such as k = 5 might fail to achieve. Furthermore, k = 9 was shown to be a safe choice for large research articles, however, for our needs, 7-shingles strike a balance between accuracy and computational efficiency, crucial for handling the extensive size of the datasets. This choice provides better computational efficiency by reducing the number of comparisons while maintaining a manageable shingle space. Lastly, we use a Jaccard similarity threshold of 0.7, which proved to be efficient for both SantaCoder and StarCoder models. A high threshold reduces false positives, leading to fewer unnecessary comparisons and lower computational overhead. Moreover, this standard threshold value has been shown to be robust for duplicate detection.

Instead of removing exact and near duplicates found against other open datasets, we add a boolean mask to our dataset. This approach enhances reproducibility by allowing researchers to filter the dataset for unique files, according to their specific requirements.

The final dataset structure is shown in the example below.

{
    "id": 538,
    "file_name": "Font.java",
    "file_path": ".../lateralgm/resources/Font.java",
    "content": "*/ package org.lateralgm.resources; import java.util.EnumMap; import org.lateralgm.main.Prefs; ...",
    "size": 1,985,
    "language": "Java",
    "extension": ".java",
    "total_lines": 3,835,
    "avg_line_length": 29,834,
    "max_line_length": 567,
    "alphanum_fraction": 0,645,
    "repo_name": "lwizchz/GameMaker-HTML5-Player",
    "repo_stars": 22,
    "repo_forks": 9,
    "repo_open_issues": 0,
    "repo_license": "GPL-3.0",
    "repo_extraction_date": "9/19/2024, 2:48:21 PM (Europe/Amsterdam)"
    "exact_duplicates_stackv1": False,
    "exact_duplicates_stackv2": True,
    "near_duplicates_stackv1": True,
    "near_duplicates_stackv2": False,
     ....
 
  } 

Dataset Fields

  • id: unique ID of the file
  • file_name: name of the file extracted from its repo
  • file_path: path to the file in its repo
  • content: content of the file
  • size: size of the file
  • language: language of the file
  • total_lines: number of total lines of the file
  • avg_line_length: average line length of the file
  • max_line_length: max line length of the file
  • alphanum_fraction: alphanumeric fraction of the file
  • extension: language extension of the file
  • repo_name: complete name of the file's repo
  • repo_stars: number of stars of the file's repo
  • repo_forks: number of forks of the file's repo
  • repo_open_issues: number of open issues of the file's repo at the extraction date
  • repo_license: license of the file's repo
  • repo_extraction_date: extraction date of file's repo
  • exact_duplicates_pubdataset: boolean flag stating if there are any exact duplicate files found against another public dataset (The Stackv2, The Stack, RedPajama, GithubCode, CodeParrot)
  • near_duplicates_pubdataset: boolean flag stating if there are any near duplicate files found against another public dataset (The Stackv2, The Stack, RedPajama, GithubCode, CodeParrot)

The distribution of the languages in The Heap is presented in the table below. The third column shows the number of files collected after filtering based on file size and word count. The last column indicates the number of files remaining after removing exact duplicates within the dataset, with exact and near duplicates compared to other datasets flagged among the remaining files.

Programming languages included in The Heap

Language Repositories Raw Files Unique Files
Ada 676 41,367 34,068
Agda 142 5,483 3,021
ANTLR 101 564 538
Apex 254 17,833 7,561
Assembly 7,100 208,896 101,093
C 50,000 16,585,280 3,076,470
C# 50,000 5,906,716 3,257,456
C++ 50,000 14,891,856 4,469,823
Clojure 27,107 380,567 269,118
Cobol 241 2,242 1,172
Common Lisp 796 45,083 13,922
Coq 477 54,137 22,549
Cuda 1,191 26,948 12,418
Crystal 368 11,606 6,818
D 1,185 185,630 54,034
Dart 11,907 484,935 412,675
EJS 1,475 15,513 12,832
Elixir 2,371 643,856 102,874
Emacs Lisp 377 8,260 7,312
Erlang 1,240 55,932 27,322
F# 876 22,152 13,282
Forth 222 28,287 5,129
Go 50,000 8,506,379 2,328,529
Groovy 2,198 60,299 47,366
Hack 1,379 84,916 37,189
Haskell 8,023 122,788 106,583
Java 50,000 6,989,601 5,168,193
JavaScript 50,000 8,289,901 1,907,803
Julia 2,859 46,284 36,830
Kotlin 21,665 1,467,343 1,042,136
Less 433 17,276 7,308
Lua 42,241 4,605,230 905,120
Mathematica 1,528 164,498 21,208
Matlab 20,828 1,051,354 599,085
NetLogo 332 900 855
NewLisp 35 5,819 5,123
Nix 1,892 75,093 70,407
Objective-C 7,700 1,899,714 520,332
OCaml 1,961 121,890 60,863
Pascal 5,218 330,832 180,652
Perl 14,673 1,798,520 224,753
PHP 50,000 12,707,727 3,310,243
Processing 2,950 24,723 20,304
Prolog 1,071 38,995 17,570
Python 50,000 2,290,182 1,595,919
R 44,993 589,139 11,679
Raku 158 1384 689
Ruby 13,378 1,579,635 662,915
Rust 42,847 2,496,177 802,707
Scala 5,893 749,370 210,630
Scheme 1,878 106,620 50,222
Scilab 199 4,531 3,896
SQL 130 47,185 40,800
Starlark 146 524 487
Swift 13,924 633,819 434,849
Vue 14,858 457,605 321,502
WebAssembly 68 834 544
Total 733,564 96,945,943 32,666,778
Downloads last month
101