Rithik Linkon
Rithik Linkon

Reputation: 3

Why does DDL use Interpreter and DML use compiler?

I am currently doing DBMS course. While studying DDL and DML I came to realize that DDL use Interpreter and DML use compiler. Interpreter execute codes line by line and Compiler executes whole code at once. So what was the intention behine DDL using interpreter and DML using compiler.

Upvotes: 0

Views: 57

Answers (2)

SQLpro
SQLpro

Reputation: 5171

There is no interpreter for DDL or DML queries in a RDBMS. The only part of SQL code that relies on an interpreter is the PSM (Persistent Stored Modules) collection of stored procedures, triggers and user defined functions (UDFs).

DDL commands like CREATE, ALTER or DROP just execute many DML queries on system tables. As an example, executing a CREATE TABLE statement

  1. inserts a row into the "tables" system table with the name of the table
  2. insert many rows into the "columns" system table with name and datatype of columns
  3. inserts zero or more rows into the "table constraints" system table with the constraint characteristics

etc.

Upvotes: 0

LMA
LMA

Reputation: 392

The reason behind it is performance.

DDL (Data Definition Language) gives you the schema for your DB; it creates tables with fields etc. You want this to take effect immediately. That's why you use an interpreter. Also your schema most likely won't change that often compared to DML.

In DML (Data Manipulation Language) it's another story. Its challenging and difficult tasks can't be executed immediately, hence the compiler.

A simple rule of thumb (there is more to it) is that an interpreter acts faster initially but the longer it runs the more inefficient it gets compared to a compiler.

Upvotes: -1

Related Questions