0% found this document useful (0 votes)
31 views

What Is SQL?

SQL is a standard language for managing relational databases. It allows users to define, manipulate, and query databases. SQL statements like SELECT, UPDATE, DELETE, and INSERT allow users to retrieve, modify, and add data to databases. SQL can also define database structures using statements like CREATE DATABASE, CREATE TABLE, and ALTER TABLE. SQL is divided into data manipulation language and data definition language.

Uploaded by

Franklin Raj C
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

What Is SQL?

SQL is a standard language for managing relational databases. It allows users to define, manipulate, and query databases. SQL statements like SELECT, UPDATE, DELETE, and INSERT allow users to retrieve, modify, and add data to databases. SQL can also define database structures using statements like CREATE DATABASE, CREATE TABLE, and ALTER TABLE. SQL is divided into data manipulation language and data definition language.

Uploaded by

Franklin Raj C
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

SQL is a standard language for accessing and manipulating databases.

What is SQL?
y y y

SQL stands for Structured Query Language SQL lets you access and manipulate databases SQL is an ANSI (American National Standards Institute) standard

What Can SQL do?


y y y y y y y y y y

SQL can execute queries against a database SQL can retrieve data from a database SQL can insert records in a database SQL can update records in a database SQL can delete records from a database SQL can create new databases SQL can create new tables in a database SQL can create stored procedures in a database SQL can create views in a database SQL can set permissions on tables, procedures, and views

SQL is a Standard - BUT....


Although SQL is an ANSI (American National Standards Institute) standard, there are many different versions of the SQL language. However, to be compliant with the ANSI standard, they all support at least the major commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE) in a similar manner.

RDBMS
RDBMS stands for Relational Database Management System. RDBMS is the basis for SQL, and for all modern database systems like MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.

The data in RDBMS is stored in database objects called tables. A table is a collections of related data entries and it consists of columns and rows.

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:
y y y y

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:
y y y y y y y

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

       

About Select Query About Distinct Keyword About Where clause About And & Or About Order by About Insert Query About Update Query About Delete Query

About Select Query


Table : EMP ENo integer Ename varchar(50) DOB datetime Sal numeric(11,2) Age int SELECT => SELECTION, PROJECTION >> Select * from EMP; >> Select * from EMP where age>50;

About Select Query with where clause:


SELECT field_name(s) FROM table_name WHERE conditions

>> select Ename, sal from EMP where ENo=555; >> select Sal + 100 from EMP; //Using Arithmetic

About Select Query using AND & OR:


>> select * from EMP where age>50 and sal>7000; >> select * from EMP where age>50 or sal>7000;

About Select Query using DISTINCT keyword:


>> select distinct * from EMP; >> select distinct Ename from EMP;

About Select Query using TOP keyword:


>>select top 5 * from EMP; >>select top 50 percent * from EMP;

About Select Query using ORDER BY clause:


>>select * from EMP order by Ename ASC >>select * from EMP order by Ename DESC

About Select Query using Aggrigate functions:


>>select count(*) from EMP >>select sum(sal) from EMP >>select max(sal) from EMP >>select min(sal) from EMP

About Select Query using BETWEEN Operator:


>> select * from EMP where age between 30 and 50 >> select * from EMP where age>30 and age<50

About Select Query using LIKE Operator:


>>select * from EMP where Ename LIKE J%; >>select * from EMP where Ename LIKE %J; >>select * from EMP where Ename LIKE R-j-;

About UPDATE keyword:


UPDATE table_name SET field_name1=value, field_name2=value,.. WHERE [condition] Ex: UPDATE EMP SET Ename=Raj, sal=5566.77 WHERE Eno=555;

About DELETE keyword:


DELETE FROM table_name WHERE [condition] >> DELETE FROM EMP; >> DELETE FROM EMP where Eno=666;

About DROP keyword:


DROP TABLE table_name; >> DROP TABLE EMP;

You might also like