1 / 7

SQL Data Definition Language (DDL)

SQL Data Definition Language (DDL). Data definition language. SQL Structured Query Language ISO / ANSI standard SQL = DDL + DML DDL = Data Definition Language A part of SQL Used to create objects in the database Database, table, view, etc . General syntax Create object_type object_name

meda
Télécharger la présentation

SQL Data Definition Language (DDL)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SQL Data Definition Language (DDL) SDL Data Definition Language (DDL)

  2. Data definition language • SQL • Structured Query Language • ISO / ANSI standard • SQL = DDL + DML • DDL = Data Definition Language • A part of SQL • Used to create objects in the database • Database, table, view, etc. • General syntax • Create object_type object_name • Create table someName … • Alter table someName • Drop table someName SDL Data Definition Language (DDL)

  3. Create table general syntax • Create table someName( firstColumn datatype constraints, secondColumn datatype constraints, …. ) SDL Data Definition Language (DDL)

  4. Special data types • PK (primarykey) • NN (Null / not null) • Where null is allowed (or not) for the field • UQ (Unique index) • AI Auto Incremental • Used to generate number • Usually for generation of primary key values • Works with int • Default • The field has a default value • Used if the user does not supply any data in the INSERT statement SDL Data Definition Language (DDL)

  5. Drop table • Deletes an existing table • All the data will be deleted as well! • No possible if other tables are referring (foreign keys) the deleted table SDL Data Definition Language (DDL)

  6. Alter table • Used to change and existing table • Add / remove columns • Add / remove constraints • Fairly complex syntax • If the table is empty it might be easier to drop an re-create the table SDL Data Definition Language (DDL)

  7. Using the GUI Tool • MS Sql Workbench has a GUI tool for creating, altering and dropping table, etc. • Create the tables with relevant columns SDL Data Definition Language (DDL)

More Related