SQL which basically, stands for structured query language is a standard language for accessing and manipulating the database.
Structured query language is also known as the SQL(SEQUEL) is an important query language that is often being used in all various types of applications.
Data analysts as well as the developers learn and make use of the SQL because it integrates well with the various programming languages. Lets consider an example, they can merge or unite with the Structured Query Language queries with the Java programming language so that it can construct the high-performing data processing applications with vital Structured Query Language database systems such as Oracle or MS Structured Query Language Server. Structured Query Language is also been often easy to learn as it make uses of the common English keywords in its statements
SQL came into existing in the 1970s which is based on the relational data model, which was initially called as the structured English query language (SEQUEL). The term was later shortened to SQL. The Oracle which is known by Relational Software which suits the first vendor offer a commercial SQL relational database management system.
Things SQL can do:
- Execute queries
- Retrieve data
- Update record
- Delete record
- Insert data
- Create new data
Statements: statement is general form or general term for piece of complete correct SQL which we can send to DBMS. Queries are used to retrieve the data based on the specific criteria whereas statement has effect on schemas and data which will control the transactions, connections etc.
SQL statement will include semicolon; which is not required in every platform and whitespace will be ignored in SQL statements and queries which make it easy to form the code for humans to read it.
Benefits:
- SQL statement has wider scope than query, which is used for serving different purposes.
- Helps in creating tables, drop tables, truncate tables etc.
- Helps in getting the information from database.
Statements been categorized which are following listed:
- Data definition language (DDL) statement
- Data manipulating language (DML) statement
- Transaction control statement
- Session control statements
- System control statement
- Embedded SQL statement
Data definition language (DDL): it is component of SQL which is used to create a modified structure of database that is all the structural operations which are performed on a database will be controlled by this language.
- If we want to create table in database, we use data definition language. (DDL)
- If we want to delete table in database or delete data then we use data definition language. (DDL)
- If we want to rename table name in database then we use data definition language. (DDL)
- Commands of Data Definition Language which are auto committed which means its permanently saves all the changes in the database system
Its also called as Data Description Language.
Commands
- Create
- Drop
- Alter
- Rename
- Truncate
Create command: if we want to make a new database or make a new table, we use this command.
Syntax of create command is given by:
CREATE TABLE <table name>
{
Column_name 1 datatype;
Column_name 2 datatype;
.
.
}
Example 1: create table employee
{
Emp id INT,
Ename char,
Age int,
City char
Phone no varchar,
};
This creates table as:
employee
Emp id | Ename | Age | city | Phone no |
Example 2: create table student
{
Sname char,
Roll no int,
Marks int,
Sem varchar,
Phone no varchar
};
Creates the table:
student
sname | Roll no | marks | sem | Phone no |
2. drop command: this command will allow to remove entire database object from the database. It also deletes table, index or view.
Syntax is given by:
Drop table< table name>
OR
DROP DATABASE <database name>
Example 1: DROP table employee;
OR
DROP database employee;
This removes entire table of employee which has been created
Example 2: DROP table student;
OR
DROP database student;
This removes entire table of student which has been created.
It we want to remove individual records then use delete command
Questions
- What are SQL statements? Explain
- Write a example for create and drop command
2 Responses
SQL which basically, stands for structured query language is a standard language for accessing and manipulating the database.
SQL statements:
Data definition language (DDL) statement
Data manipulating language (DML) statement
Transaction control statement
Session control statements
System control statement
Embedded SQL statement
create table student
{
Sname char,
Roll no int,
Marks int,
Sem varchar,
Phone no varchar
};
Creates the table:
student
sname Roll no marks sem Phone no
DROP table student;
OR
DROP database student;
This removes entire table of student which has been created