DDL & DML

SQL stands for Structured Query Language and it is used to communicate with databases. SQL can be divided into two categories: DDL and DML.

DDL stands for Data Definition Language and it is used to define the structure of the database, such as tables, columns, constraints, indexes, etc. DDL commands include CREATE, ALTER, DROP, RENAME, and TRUNCATE.

DML stands for Data Manipulation Language and it is used to insert, update, delete, and query data from the database. DML commands include SELECT, INSERT, UPDATE, DELETE, and MERGE.

Here are some examples of SQL DDL and DML commands:

-- Create a table called customers with four columns: id, name, email, and phone
CREATE TABLE customers (
  id INT PRIMARY KEY,
  name VARCHAR(50) NOT NULL,
  email VARCHAR(50) UNIQUE,
  phone VARCHAR(15)
);

-- Insert a new record into the customers table
INSERT INTO customers (id, name, email, phone) VALUES (1, 'Alice', 'alice@example.com', '1234567890');

-- Update the email of the customer with id 1
UPDATE customers SET email = 'alice@gmail.com' WHERE id = 1;

-- Delete the customer with id 1
DELETE FROM customers WHERE id = 1;

-- Select all records from the customers table
SELECT * FROM customers;

Comments

Popular posts from this blog

Backup And Restore A Site Collection In SharePoint 2013

Introduction to Structured Query Language