SQL DML and DDL SQL can be divided into two parts: The Data Manipulation Language (DML) and the Data Definition Language (DDL). The query and update commands form the DML part of SQL: * SELECT - extracts data from a database * UPDATE - updates data in a database * DELETE - deletes data from a database * INSERT INTO - inserts new data into a database The DDL part of SQL permits database tables to be created or deleted. It also define indexes (keys), specify links between tables, and impose constraints between tables. The most important DDL statements in SQL are: * CREATE DATABASE - creates a new database * ALTER DATABASE - modifies a database * CREATE TABLE - creates a new table * ALTER TABLE - modifies a table * DROP TABLE - deletes a table * CREATE INDEX - creates an index (search key) * DROP INDEX - deletes an index //////////////////////////////////////////////////////////////////////////////////////////////////////////// //Selecting all data from a specific table. SELECT * FROM Albums //Selecting 3 different cols from a table called Persons. SELECT LastName,FirstName FROM Persons //////////////////////////////////////////////////////////////////////////////////////////////////////////// //In a table, some of the columns may contain duplicate values. This is not a problem, however, sometimes you will want to list only the different (distinct) values in a table. //The DISTINCT keyword can be used to return only distinct (different) values. SELECT DISTINCT column_name(s) FROM table_name //////////////////////////////////////////////////////////////////////////////////////////////////////////// |