Definition
SQL stands for Structured Query Language . It is a declarative language. SQL is a computer language for storing, manipulating, and retrieving data stored in a relational database.
The basic structure of a relationship model is a table, consisting of rows and columns. Definition of data includes declaring the name of each table to be included in the database, the names and types of data for all columns in each table, issues with intermediate values between columns, and granting table management rights to prospective users. Tables can be accessed by adding new lines, deleting or updating existing lines, or by selecting lines that satisfy the given search query status.Ad Link
SQL is a computer language designed for data purposes. However, this language is not a data usage. Although relationship building provides the key elements of a relationship database, SQL supports the actual implementation of this type of database. SQL, one of the most popular languages today, is not the same as other programming languages (e.g. Java, C, C ++, etc.). Many programming languages are processes, which means they define how a system should perform its functions. SQL, which is a non-process language, focuses on the results of program functions. The nature of the software you use will determine the data application that will complete its tasks. SQL language does not have editing features for other languages. This is one reason why some programmers refer to SQL as "sub-language." Basically, you will use SQL and other languages (e.g. C #) to perform tasks.
Create Table
CREATE TABLE < Table Name >
( Column1 DataType,
Column2 DataType,
Column3 DataType
… )
How to select data from more than one table
SELECT < Column List >
FROM < Table1 > JOIN < Table2 >
ON < Table1 > < Column1 > = < Table2 > < Column1 >
Data Query Language ( DQL )
DML statements are used to query data within schema objects. The purpose of the DQL Command is to obtain schema relationships based on the query referred to.
Example of DQL:
SELECT – used to retrieve data from database.
SELECT < Column List >
FROM < Table Name >
WHERE < Search Condition >
How to order data
SELECT < Column List >
FROM < Table Name >
WHERE < Search Condition >
ORDER BY < Column List >
Data Manipulation Language ( DML )
The SQL instructions for data management that are available in the database belong to DML or Data Control Language and this includes many SQL statements.
Examples of DML:
INSERT – used to enter data in a table.
UPDATE – used to update existing data within the table.
DELETE – used to delete records in the data table.
INSERT INTO < Table Name >
( < Column List > )
UPDATE < Table Name >
SET < Column1 > = < Value1 >, < Column2 > = < Value2 >, …
WHERE < Search Condition >
DELETE FROM < Table Name >
WHERE < Search Condition >
Data Definition Language ( DDL )
DDL or Data Definition Language actually has SQL commands that can be used to define a database schema. It simply works with the definitions of a database schema and is used to create and modify the structure of database objects.
Examples of DDL commands:
CREATE – used to create a database or its objects (such as a table, index, task, view, storage process and causes).
DROP – used to remove items from the database.
ALTER- used to modify data structure.
TRUNCATE– used to delete all records in the table, including all spaces provided for records are deleted.
COMMENT – used to add ideas to the data dictionary.
RENAME – used to rename an existing item in a database.
ALERT TABLE table_name;
ALERT COLUMN column_name dataType;
DROP TABLE table_name;
TRUNCATE TABLE phonebook;
Data Control Language ( DCL )
DCL includes commands such as GRANT and REVOKE that specialize in rights, permissions and other data management systems.
GRANT- grants user access to the database.
REVOKE- remove user access rights granted using the GRANT command.
GRANT ALL PRIVILEGES ON database_name TO database_user;
REVOKE ALL PRIVILEGES ON database_name TO database_user ;
Transaction Control Language ( TCL )
TCL commands apply to existing database transactions.
Examples of TCL commands:
COMMIT– do Transactions.
ROLLBACK– reverses a transaction in the event of an error.
SAVEPOINT– sets storage space within transactions.
SET TRANSACTION– describe the features of the process.
COMMIT;
ROLLBACK TO savepoint_name;
SAVEPOINT savepoint_name;