Content deleted Content added
m Krauss moved page Data definition language to Data definition language (SQL): the article is all about SQL |
Mindmatrix (talk | contribs) m Reverted edits by 49.185.161.75 (talk) to last version by WalkingRadiance |
||
(32 intermediate revisions by 25 users not shown) | |||
Line 1:
{{short description|Syntax for defining data structures}}
{{Distinguish|Data manipulation language}}
{{Refimprove|date=December 2012}}▼
{{Multiple issues|
In the context of [[SQL]], '''data definition''' or '''data description language''' ('''DDL''') is a syntax similar to a computer [[programming language]] for defining [[data structure]]s, especially [[database schema]]s. DDL statements create and modify database objects such as tables, indexes, and users. Common DDL statements are <code>CREATE</code>, <code>ALTER</code>, and <code>DROP</code>.▼
▲{{Refimprove|date=December 2012}}
{{Cleanup|reason=the article focuses almost entirely on SQL.|date=June 2020}}
}}
[[File:UY3OsG1vuT-saving-a-ddl-file-in-Oracle-Developer.png|alt=Saving a ddl file in Oracle SQL Developer|thumb|Saving a ddl file in Oracle SQL Developer]]
▲In the context of [[SQL]], '''data definition''' or '''data description language''' ('''DDL''') is a syntax for creating and modifying database objects such as tables, indices, and users. DDL statements are similar to a computer [[programming language]] for defining [[data structure]]s, especially [[database schema]]s.
==History==
The concept of the data definition language and its name was first introduced in relation to the [[Codasyl]] database model, where the schema of the [[database]] was written in a [[Syntax (programming languages)|language syntax]] describing the [[Record (computer science)|records]], [[Field (computer science)|fields]], and [[Set (abstract data type)|sets]] of the user [[data model]].<ref>{{cite book|last=Olle|first=T. William|title=The Codasyl Approach to Data Base Management|year=1978|publisher=Wiley|isbn=0-471-99579-7|url-access=registration|url=https://archive.org/details/codasylapproacht00olle}}</ref> Later it was used to refer to a subset of [[Structured Query Language]] (SQL) for declaring [[Table (database)|tables]], columns, data types and [[Integrity constraints|constraints]]. [[SQL-92]] introduced a schema manipulation language and schema information tables to query schemas.<ref name="SQL92">{{cite web |title=Information Technology - Database Language SQL |url=http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt |website=SQL92 |publisher=Carnegie Mellon |
==Structured Query Language (SQL)==
Line 14 ⟶ 18:
The ''create'' command is used to establish a new database, table, index, or [[stored procedure]].
The ''CREATE'' statement in [[SQL]] creates a component in a [[relational database management system]] (RDBMS). In the SQL 1992 specification, the types of components that can be created are schemas, [[table (database)|tables]], [[View (database)|views]], domains, [[character set]]s, [[collation]]s, translations, and assertions.<ref name="SQL92" />
====CREATE TABLE statement====
Line 34 ⟶ 38:
first_name VARCHAR(50) not null,
last_name VARCHAR(75) not null,
dateofbirth DATE not null
);
</syntaxhighlight>
Some forms of ''CREATE TABLE DDL'' may incorporate DML ([[data manipulation language]])-like constructs, such as the ''CREATE TABLE AS SELECT'' (
{{cite book
| last = Allen
Line 46 ⟶ 50:
| title = The Definitive Guide to SQLite
| url = https://books.google.com/books?id=WLinoJaOUCwC
|
| edition = 2
| series = Apresspod
Line 53 ⟶ 57:
| isbn = 9781430232254
| pages = 90–91
| quote = The ''create table'' statement has a special syntax for creating tables from ''select'' statements. [...]: [...] ''create table foods2 as select * from foods;'' [...] Many other databases refer to this approach as ''
}}
</ref>
Line 66 ⟶ 70:
For example, the command to drop a table named '''employees''' is:
<syntaxhighlight lang="
DROP TABLE employees;
</syntaxhighlight>
Line 81 ⟶ 85:
For example, the command to add (then remove) a column named '''bubbles''' for an existing table named '''sink''' is:
<syntaxhighlight lang="
ALTER TABLE sink ADD bubbles INTEGER;
ALTER TABLE sink DROP COLUMN bubbles;
Line 89 ⟶ 93:
The ''TRUNCATE'' statement is used to delete all data from a table. It's much faster than ''DELETE''.
<syntaxhighlight lang="
TRUNCATE TABLE table_name;
</syntaxhighlight>
Line 98 ⟶ 102:
==Other languages==
* [[XML Schema (W3C)|XML Schema]] is an example of a DDL for [[XML]].
* [[JSON#
* [[Data_Format_Description_Language|DFDL schema]] is an example of a DDL that can describe many text and binary formats.
==See also==
Line 114 ⟶ 119:
==External links==
* [https://oracletutorial.net/alter-table-modify-column-oracle.html Oracle ALTER TABLE MODIFY column] {{Webarchive|url=https://web.archive.org/web/20210421200756/https://oracletutorial.net/alter-table-modify-column-oracle.html |date=2021-04-21 }}
* [https://oracletutorial.net/dml-ddl-commands-in-oracle.html#ddl-commands-in-oracle DDL Commands In Oracle] {{Webarchive|url=https://web.archive.org/web/20210421203338/https://oracletutorial.net/dml-ddl-commands-in-oracle.html#ddl-commands-in-oracle |date=2021-04-21 }}
{{Database}}
[[Category:Articles with example SQL code]]
|