SQL - Data Definition Language (DDL)

Undraw Environment

SQL - Data Definition Language (DDL)

About

DDL is a sql subset that manages the database metadata.

You can execute DDL statements with a SQL Request.

Example/HowTo

List

  • CREATE,
  • ALTER,
  • DROP

DDL vs the CREATE operation

With a DDL, you create a SQL Object with the CREATE statement with the create operation, you can

  • create table by copy
  • create view from a list of files containing Select statements.

Execution

If you execute a SQL fetch that contains DDL statements, you will get the following results.

id          count   statement                                              error_code   error_message
--   ------------   ----------------------------------------------------   ----------   -------------
 1              0   create table ddl_table_test\n(\n    column_name inte            0
 2              0   alter table ddl_table_test\n    owner to postgres;\n            0

A DDL script is an runtime and therefore is executed:

Example of execution at runtime

  • with the print command. If you print it 2 times, they will execute 2 times.
tabul data print (create_ddl.sql@cd)@sqlite

Note

Auto-commit

DDL statements auto-commit, so they can't be rolled back




Related HowTo
Undraw Environment
How to create a SQL view with a CREATE statement file

This Howto will show you how to create a SQL View with a SQL file that contains a CREATE SQL statement with the Tabul table create command. You should have Tabulify installed on your computer: ...
Undraw Environment
How to execute a procedure in MySQL ?

This howto shows you how to create and execute a SQL Procedure in MySQL. This example has been taken from the official...
Undraw Environment
How to execute a procedure in Postgres?

This howto shows you how to create and execute a SQL Procedure in Postgres. This example has been taken from the official...
Undraw Environment
SQL - How to execute SQL DDL statements (CREATE, ALTER, ..)?

This howto will show you how to execute a SQL DDL query that contains multiple: DDL statements (ie CREATE, ALTER) and an DML (INSERT) The file containing this query is located below the howto...
Undraw Environment
Tabulify - How to create a table with a CREATE Sql statement file

This Howto will show you how to create a SQL table with a SQL file that contains a ''CREATE'' SQL statement
Undraw Environment
Tabulify - How to create a table with a CREATE Sql statement file

This Howto will show you how to create a SQL table with a SQL file that contains a ''CREATE'' SQL statement

Task Runner