This blog is the first of a series that I will write on the comparison between different DBMS on which I work daily:
-- DB2 (> 9.x)
-- Oracle (>9i)
-- MySql (>5.x)
-- PostgreSQL (>7.4)
-- SQL Server (>2005)
-- Derby (>10.x)
-- DB2 (> 9.x)
-- Oracle (>9i)
-- MySql (>5.x)
-- PostgreSQL (>7.4)
-- SQL Server (>2005)
-- Derby (>10.x)
Differences between DDL and DML.
The DDL are SQL statements through which you create / change / delete the structure of a database. Typical instructions are "CREATE TABLE, ALTER TABLE, DROP TABLE,..." .
The DDL are SQL statements through which you create / change / delete the structure of a database. Typical instructions are "CREATE TABLE, ALTER TABLE, DROP TABLE,..." .
The DML are the instructions that would change the data in a database.
Typical instructions are "INSERT, UPDATE, DELETE".
The first difference is inside management of transactions.
Reading wiki,It shows the meaning of a transaction: it's part of DML.
Reading wiki,It shows the meaning of a transaction: it's part of DML.
Among all databases I listed above PostgreSQL is an exception.
This is why through PostgreSQL you can run into DDL with DML transactions.
For example:
START TRANSACTION; (or equivalent)
CREATE TABLE foo (id integer);
Insert into foo (1,2);
COMMIT;
The insert is obviously wrong but the result is that you will have an empty table (Table foo) created inside all databases except for PostgreSQL.
Having the ability to run DDL in transaction is good, especially when you have to run scripts sql that are very long and you do not want to drop and create a data structure every time.
This is why through PostgreSQL you can run into DDL with DML transactions.
For example:
START TRANSACTION; (or equivalent)
CREATE TABLE foo (id integer);
Insert into foo (1,2);
COMMIT;
The insert is obviously wrong but the result is that you will have an empty table (Table foo) created inside all databases except for PostgreSQL.
Having the ability to run DDL in transaction is good, especially when you have to run scripts sql that are very long and you do not want to drop and create a data structure every time.