| Introduction to SQL |
| |
| Data Manipulation Language (DML) |
| |
| SQL can be termed as DML i.e. Data Manipulation Language. Database is manipulated so as to insert, update and delete records. |
| |
| CREATE, ALTER or DROP a database, table, index etc. This section also describes SELECT INTO which is used create a back up of a database table. |
| |
| The commands have been described with appropriate example one at a time covering all the clauses. |
| |
| |
| SQL Create |
| Create a Database |
| CREATE statement can be used to create a database. A database is nothing but a collection of tables which are related to each other. The inter-relation amongst the tables in a database is created by attributes/fields which may be common to more than one table. |
| |
| Syntax: |
| CREATE DATABASE database_name |
| |
| |
| Create Table |
| With CREATE TABLE, a new table can be created. A table can be considered as a basic structure within which data is stored. It consists of rows and columns. A row represents a single record while a column represents attributes/fields which can be thought of as one of the components contributing to make a record. While creating a table, data types have to be mentioned for each field. |
| |
| Here are the most common Data Types: |
| |
|
| |
| The following statements/commands consist of DDL portion of SQL: |
| Select : Retrieves desired records from a database table. |
| |
| Update : Updates/modifies records in a database table. |
| |
| Delete : Deletes records from a database table. |
| |
| Insert into: Inserts new records into a database table. |
| |
| |
|
|
| |
| |