Data definition language

Saving a ddl file in Oracle SQL Developer
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 structures, especially database schemas. Common examples of DDL statements include CREATE, ALTER, and DROP. If you see a .ddl file, that means the file contains a statement to create a table. Oracle SQL Developer contains the ability to export from an ERD generated with Data Modeler to either a .sql file or a .ddl file.

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 language syntax describing the records, fields, and sets of the user data model.[1] Later it was used to refer to a subset of Structured Query Language (SQL) for declaring tables, columns, data types and constraints. SQL-92 introduced a schema manipulation language and schema information tables to query schemas.[2] These information tables were specified as SQL/Schemata in SQL:2003. The term DDL is also used in a generic sense to refer to any formal language for describing data or information structures.

Structured Query Language (SQL)

Many data description languages use a declarative syntax to define columns and data types. Structured Query Language (SQL), however, uses a collection of imperative verbs whose effect is to modify the schema of the database by adding, changing, or deleting definitions of tables or other elements. These statements can be freely mixed with other SQL statements, making the DDL not a separate language.

CREATE statement

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, tables, views, domains, character sets, collations, translations, and assertions.[2] Many implementations extend the syntax to allow creation of additional elements, such as indexes and user profiles. Some systems, such as PostgreSQL and SQL Server, allow CREATE, and other DDL commands, inside a database transaction and thus they may be rolled back.[3][4]

CREATE TABLE statement

A commonly used CREATE command is the CREATE TABLE command. The typical usage is:

CREATE TABLE [table name] ( [column definitions] ) [table parameters]

The column definitions are:

  • A comma-separated list consisting of any of the following
  • Column definition: [column name] [data type] {NULL | NOT NULL} {column options}
  • Primary key definition: PRIMARY KEY ( [comma separated column list] )
  • Constraints: {CONSTRAINT} [constraint definition]
  • RDBMS specific functionality

An example statement to create a table named employees with a few columns is:

CREATE TABLE employees (
    id            INTEGER       PRIMARY KEY,
    first_name    VARCHAR(50)   not null,
    last_name     VARCHAR(75)   not null,
    mid_name      VARCHAR(50)   not null,
    dateofbirth   DATE          not null
);

Some forms of CREATE TABLE DDL may incorporate DML (data manipulation language)-like constructs, such as the CREATE TABLE AS SELECT (CTaS) syntax of SQL.[5]

DROP statement

The DROP statement destroys an existing database, table, index, or view.

A DROP statement in SQL removes a component from a relational database management system (RDBMS). The types of objects that can be dropped depends on which RDBMS is being used, but most support the dropping of tables, users, and databases. Some systems (such as PostgreSQL) allow DROP and other DDL commands to occur inside of a transaction and thus be rolled back. The typical usage is simply:

DROP objecttype objectname.

For example, the command to drop a table named employees is:

DROP TABLE employees;

The DROP statement is distinct from the DELETE and TRUNCATE statements, in that DELETE and TRUNCATE do not remove the table itself. For example, a DELETE statement might delete some (or all) data from a table while leaving the table itself in the database, whereas a DROP statement removes the entire table from the database.

ALTER statement

The ALTER statement modifies an existing database object.

An ALTER statement in SQL changes the properties of an object inside of a relational database management system (RDBMS). The types of objects that can be altered depends on which RDBMS is being used. The typical usage is:

ALTER objecttype objectname parameters.

For example, the command to add (then remove) a column named bubbles for an existing table named sink is:

ALTER TABLE sink ADD bubbles INTEGER;
ALTER TABLE sink DROP COLUMN bubbles;

TRUNCATE statement

The TRUNCATE statement is used to delete all data from a table. It's much faster than DELETE.

TRUNCATE TABLE table_name;

Referential integrity statements

Another type of DDL sentence in SQL is used to define referential integrity relationships, usually implemented as primary key and foreign key tags in some columns of the tables. These two statements can be included in a CREATE TABLE or an ALTER TABLE sentence;

Other languages

See also

References

  1. ^ Olle, T. William (1978). The Codasyl Approach to Data Base Management. Wiley. ISBN 0-471-99579-7.
  2. ^ a b "Information Technology - Database Language SQL". SQL92. Carnegie Mellon. Retrieved 12 November 2018.
  3. ^ Laudenschlager, Douglas; Milener, Gene; Guyer, Craig; Byham, Rick. "Transactions (Transact-SQL)". Microsoft Docs. Microsoft. Retrieved 12 November 2018.
  4. ^ "PostgreSQL Transactions". PostgreSQL 8.3 Documentation. PostgreSQL. 7 February 2013. Retrieved 12 November 2018.
  5. ^ Allen, Grant (2010). The Definitive Guide to SQLite. Apresspod. Mike Owens (2 ed.). Apress. pp. 90–91. ISBN 9781430232254. Retrieved 2012-10-02. 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 CTaS, which stands for Create Table as Select, and that phrase is not uncommon among SQLite users.

Read other articles:

FarzaDistrikNegara AfghanistanProvinsiProvinsi KabulPopulasi (2005)[1] • Total15.139Kode Pos1059 Farza, Kabul adalah distrik di Provinsi Kabul, Afghanistan. Jumlah penduduk di provinsi ini pada tahun 2005 yaitu 15,139 jiwa. Referensi ^ (Inggris) Kabul Province. Program Pangan Dunia. Diarsipkan dari versi asli tanggal 2012-12-20. Diakses tanggal 2012-09-19.  lbsProvinsi KabulIbu kota: KabulDistrik Bagrami Char Asiab Deh Sabz Farza Guldara Istalif Kabul Kalaka...

 

Sialkot سیالکوٹKota Municipal Corporation SialkotMunicipal Corporation logoJulukan: Kota Iqbal[1]SialkotLocation in PakistanTampilkan peta Punjab, PakistanSialkotSialkot (Pakistan)Tampilkan peta PakistanKoordinat: 32°29′33″N 74°31′52″E / 32.49250°N 74.53111°E / 32.49250; 74.53111Koordinat: 32°29′33″N 74°31′52″E / 32.49250°N 74.53111°E / 32.49250; 74.53111Negara PakistanProvinsiTemplat:Country data...

 

Historical house museum in Ontario, Canada.Lambton HouseEstablished1847Location4066 Old Dundas Street Toronto, Ontario, Canada.Typehistorical house museumWebsitewww.lambtonhouse.org Lambton House is a historic former inn in Toronto, Ontario, Canada. It is the last remaining building from the former village of Lambton Mills along the Humber River. The inn was established in 1847, with its present building erected in 1860. History The original structure was built in 1847, Lambton House was part...

Манга тайсёマンガ大賞 Страна  Япония Награда за лучшую серию манги Учредитель Исполнительный комитет Манги тайсё Основание 2008 Всего 17 Первый обладатель Синъити Исидзука за Gaku: Minna no Yama Последний обладатель Инухико Доронода за Kimi to Uchu o Aruku Tame ni Сайт mangataisho.com Манга тайсё ...

 

Citrus Periode Tortonian–Sekarang, 8–0 Ma[1] PreЄ Є O S D C P T J K Pg N Potongan beberapa jenis buah jerukTumbuhanJenis buahhesperidium TaksonomiDivisiTracheophytaSubdivisiSpermatophytesKladAngiospermaeKladmesangiospermsKladeudicotsKladcore eudicotsKladSuperrosidaeKladrosidsKladmalvidsOrdoSapindalesFamiliRutaceaeSubfamiliAurantioideaeTribusCitreaeGenusCitrus Linnaeus, 1753 Sinonim taksonFortunella Spesies dan hibridaSpesies leluhur: Citrus maxima – Jeruk bali Citrus medi...

 

2009 Charlotte mayoral election← 20072011 →   Nominee Anthony Foxx John Lassiter Party Democratic Republican Popular vote 55,080 51,841 Percentage 51.48% 48.45% Mayor before election Pat McCrory Republican Elected Mayor Anthony Foxx Democratic Elections in North Carolina Federal government U.S. President 1792 1796 1800 1804 1808 1812 1816 1820 1824 1828 1832 1836 1840 1844 1848 1852 1856 1860 1868 1872 1876 1880 1884 1888 1892 1896 1900 1904 1908 1912 1916 192...

Strategy for reducing disease transmission This article is about the strategy for reducing disease transmission. For the sepsis management strategy, see Sepsis § Source control. For other uses, see Source control (disambiguation). Source control is recommended for members of the general public during severe epidemics, especially in crowded indoor areas such as stores. Source control is a strategy for reducing disease transmission by blocking respiratory secretions produced through speak...

 

باريس تورز 1960 تفاصيل السباقسلسلة54. باريس تورزمنافسةسوبر برستيج بيرنود 1960التاريخ2 أكتوبر 1960البلد فرنساالمنصةالفائز جو دي هان (Rapha-Gitane-Dunlop  [لغات أخرى]‏)الثاني Michel Stolker [الإنجليزية]‏الثالث Luis Otaño [الإنجليزية]‏ ▶19591961◀ توثيق باريس تورز 1960 هو سباق دراجا�...

 

Alpicat municipio de Cataluña Escudo Iglesia de San Bartolomé AlpicatUbicación de Alpicat en España AlpicatUbicación de Alpicat en la provincia de LéridaPaís  España• Com. autónoma  Cataluña• Provincia Lérida• Comarca SegriáUbicación 41°40′05″N 0°33′22″E / 41.668055555556, 0.55611111111111• Altitud 260 mSuperficie 15,3 km²Población 6394 hab. (2023)• Densidad 410,78 hab./km�...

PergeSede arcivescovile titolareArchidioecesis PergensisPatriarcato di CostantinopoliMappa della diocesi civile di Asia (V secolo)Arcivescovo titolaresede vacante IstituitaXVIII secolo StatoTurchia Arcidiocesi soppressa di PergeEretta? Soppressa? Dati dall'annuario pontificio Sedi titolari cattoliche Manuale Vista aerea del sito archeologico di Perge. L'agorà di Perge. L'arcidiocesi di Perge (in latino Archidioecesis Pergensis) è una sede soppressa del patriarcato di Costantinopoli e u...

 

Political party in Canada Option nationale LeaderSol ZanettiFounderJean-Martin AussantFoundedOctober 31, 2011 (2011-10-31)DissolvedJanuary 1, 2018 (2018-01-01)Split fromParti QuébécoisMerged intoQuébec solidaireHeadquartersLongueuil, QuebecIdeologyQuebec sovereigntismQuebec nationalismProgressivismSocial democracySocial liberalismPolitical positionCentre-left[1]Websitewww.optionnationale.orgPolitics of QuebecPolitical partiesElection...

 

Professor at the Hebrew University of Jerusalem (1945–2015) Robert Wistrich in 2013 Robert Solomon Wistrich (April 7, 1945 – May 19, 2015) was a scholar of antisemitism, considered one of the world's foremost authorities on antisemitism.[1][2] The Erich Neuberger Professor of European and Jewish history at the Hebrew University of Jerusalem, and he was also the head of the university's Vidal Sassoon International Center for the Study of Antisemitism (SICSA).[2]...

German social theorist and philosopher (born 1929) Jürgen HabermasHabermas in 2014BornJürgen Habermas (1929-06-18) 18 June 1929 (age 94)Düsseldorf, Rhine Province, Prussia, GermanyEducationUniversity of Bonn (PhD)University of Marburg (Dr. phil. hab.)Spouse Ute Wesselhöft ​(m. 1955)​ChildrenTilmann (b. 1956)Rebekka (1959–2023)Judith (b. 1967)EraContemporary philosophyRegionWestern philosophySchoolContinental philosophyCritical theoryNeopragmatism[1&...

 

County in Kansas, United States County in KansasRepublic CountyCountyRepublic County Courthouse in Belleville (2010)Location within the U.S. state of KansasKansas's location within the U.S.Coordinates: 39°48′N 97°38′W / 39.800°N 97.633°W / 39.800; -97.633Country United StatesState KansasFoundedFebruary 27, 1860Named forRepublican RiverSeatBellevilleLargest cityBellevilleArea • Total720.31 sq mi (1,865.6 km2) • La...

 

Dinastía Románov Романовы Familias relacionadas Casa de Skavronsky Casa de Holstein-Gottorp País(es) Imperio rusoTítulos Emperador de Rusia Fundación 1613Destitución Revolución de Febrero de 1917MiembrosFundador Filareto I de MoscúÚltimo gobernante Isabel I de Rusia (línea agnática)Nicolás II de Rusia (línea cognática)Jefe actual Disputado desde 1992Maria I de RusiaPrincipe Alexis Andreievich de Rusia[editar datos en Wikidata] La dinastía Románov (en ruso: Р...

1141年《紹興和議》後宋金版圖 紹興和議是南宋和金朝在宋紹興十一年(1141年)達成的第二次和議,宋高宗在急於求和下,接受了金朝的苛刻條件。此和議達至宋金近一百年南北分治的局面,大致以秦嶺淮河線為界。 背景 紹興七年(1137年)宋高宗以“宣和皇后春秋高,朕思之不遑甯處,屈己請和,正為此耳。”為由,籲向金朝議和,次年任秦檜為相,圖為南宋·《八相圖》...

 

Artikel ini tidak memiliki referensi atau sumber tepercaya sehingga isinya tidak bisa dipastikan. Tolong bantu perbaiki artikel ini dengan menambahkan referensi yang layak. Tulisan tanpa sumber dapat dipertanyakan dan dihapus sewaktu-waktu.Cari sumber: Gromia sphaerica – berita · surat kabar · buku · cendekiawan · JSTOR Gromia sphaerica adalah amuba testis yang berbentuk bulat besar, organisme yang bersel tunggal ini dapat dikelompokkan ke dalam protis...

 

Meistriliiga2016 Généralités Sport Football Organisateur(s) EJL Édition 26e Date Du 4 mars au 19 novembre 2016 Participants 10 équipes Site web officiel Site officiel Palmarès Tenant du titre FC Flora Tallinn Promu(s) en début de saison JK Tarvas Rakvere Vainqueur FC Infonet Tallinn Meilleur(s) buteur(s) Evgeny Kabaev (25) Navigation Meistriliiga 2015 Meistriliiga 2017 modifier La saison 2016 du Championnat d'Estonie de football est la 26e de l'élite du football estonien. Les dix mei...

Pemra ÖzgenPemra Özgen nel 2019Nazionalità Turchia Altezza170 cm Peso60 kg Tennis Carriera Singolare1 Vittorie/sconfitte 572 - 485 (54.12%) Titoli vinti 0 WTA, 18 ITF Miglior ranking 184ª (12 agosto 2019) Ranking attuale ranking Risultati nei tornei del Grande Slam  Australian Open Q1 (2019, 2020, 2021)  Roland Garros Q1 (2020, 2021)  Wimbledon Q2 (2019)  US Open Q2 (2013) Doppio1 Vittorie/sconfitte 305 - 257 (54.27%) Titoli vinti 0 WTA, 23 ITF Miglior ranking 179...

 

The United States of America—Post-Cold War Era1991–2008Bill Clinton, George W. Bush, and his father George H. W. Bush, 2005LocationUnited StatesIncludingReagan EraWar on TerrorWar on drugsThird Industrial RevolutionNew Great MigrationPresident(s)George H. W. BushBill ClintonGeorge W. BushKey events 1991-2001 Gulf War NAFTA Los Angeles Riots Hurricane Andrew Republican Revolution WTC bombing Oklahoma City bombing Impeachment of Bill Clinton Columbine massacre Launch of the Web Early 2000s...