SQL (Structured Query Language) is an ANSI standard computer language that allows you to access a database by execute queries, retrieve, insert, delete, update records etc. SQL is a standard language for accessing databases.
Q :What is SQL?
• SQL stands for Structured Query Language
• SQL is pronounced as /ˌɛs.kjuːˈɛl/
• SQL is designed for manipulate data in relational database management system
Q :What can you do with SQL?
• SQL can retrieve and update data from relational database management system by using data manipulation language.
• SQL can create and modify database schema and database objects such as tables, views, indexes... via data definition language.
• SQL can grant or revoke authorization to user through data control language.
SQL Data Manipulation Language (DML)
SQL data manipulation language (DML) is a main part of SQL statements. SQL DML allows you to retrieve data from the database tables in relational database management system (RDBMS). In addition, SQL DML allows you change or delete data from the database tables by using UPDATE and DELETE statements. Here are all the SQL statements related to the SQL data manipulation language:
SQL Syntax
1)SQL SELECT:-
SELECT Company, Country FROM Customers WHERE Country <> 'india'
SQL Result
Company Country
Wipro Delhi
HCL Noida
TCS Pune
2)SQL DELETE
SQL DELETE statement allows you to delete one or more records in a database table. The syntax of SQL DELETE statement is as follows:
1 DELETE FROM table_name
2 WHERE conditions
If you want to remove employee number 3 just execute the following query:
1 DELETE FROM employees
2 WHERE employeeID = 3
3) SQL INSERT :-
1 INSERT INTO table_name (column1, column2…)
2 VALUES (value1, value2,…).
example of inserting data into the Shippers table by using SQL INSERT statement.
1 INSERT INTO Shippers (companyName, phone)
2 VALUES ('Shippers','1-800-222-0451')
Insert multiple records into a database table
SQL INSERT statement also allows you to insert multiple records into a database table at a time. Here is the syntax:
1 INSERT INTO shippers(companyName,phone)
2 VALUES ('zte','1-800-782-1235'),
3 ('cms','1-800-225-1234')
4)SQL UPDATE
1 UPDATE table_name
2 SET column1 = value1,
3 column2 = value2
4 WHERE condition
Ex:- Suppose one of employee in the company get married and need to change her last name, so you have to make the change by using the SQL UPDATE statement. Here is the query to do so:
1 UPDATE employees
2 SET lastname = 'ram'
3 WHERE employeeID = 3.
No comments:
Post a Comment