Show What is SQL?SQL stands for Structured Query Language, as it is the special purpose domain-specific language for querying data in Relational Database Management System (RDBMS). Microsoft SQL Server, MySQL, Oracle, etc. use SQL for querying with slight syntax differences. Types of SQL StatementsSQL statements are categorized into four different types of statements, which are
Let's see one by one. DMLIn Data Manipulation Language(DML), we have four different SQL statements, Select, Insert, Update, and Delete. SELECT StatementThe SELECT statement is used to select records from the table, with or without a condition.Example
INSERTINSERT statement is used to insert a set of values into a database table. Insert statement it used with Values. Example- Insert Into Student (Rank, StudentName, Mark) Values(1,’Kumar’,450)UPDATEThe UPDATE statement is used to update existing values in a table, which is based on some condition.Example
DELETEDelete statement is used to delete the existing record in the table, which is based on some condition.Example
DDLIn Data Definition Language (DDL), we have three different SQL statements. CREATECREATE statement is used to create a new table in an existing database. CREATE statement is also used to create other database object such as a stored procedure, function, etc.Example
ALTERAlter statement can add a column, modify a column, drop a column, rename a column or rename a table.Example
DROPSQL DROP TABLE statement is used to remove a table definition and all the data, indexes, triggers, constraints and permission specifications for the table.Example
TRUNCATETRUNCATE SQL query removes all rows from a table, without logging the individual row deletions.Example
DCLIn Data Control Language(DCL), it defines the control over the data in the database. We have two different commands, which are GRANTGrant is allowed to do the specified user to the specified tasks. Syntax GRANT privilege_nameON object_name TO {user_name |PUBLIC |role_name} [WITH GRANT OPTION]; REVOKEIt is used to cancel previously granted or denied permissions. Syntax REVOKE privilege_nameON object_name FROM {user_name |PUBLIC |role_name} TCLIn Transaction Control Language (TCL), the commands are used to manage the transactions in the database. These are used to manage the changes made by DML statements. It also allows the statements to be grouped together into logical transactions. COMMITCommit command is used to permanently save any transaction into the database.Syntax Commit; Read more- Commit and Rollback Commands in SQL ServerROLLBACKRollback command is used to restore the database for the last committed state. It’s also used with a save point to jump to the save point. Syntax Rollback to savepoint name Read more- Commit and Rollback in SQL ServerSAVEPOINTSAVEPOINT command is used to temporarily save a transaction so that you can roll back to that point whenever necessary. Syntax savepointsavepoint-name; Read more- What is the usage of savepointsThese are the different types of statements in the SQL language. I hope, this will be helpful for the readers. Thanks for reading. What are the 5 SQL statement types?Types of SQL Statements. Data Definition Language (DDL) Statements.. Data Manipulation Language (DML) Statements.. Transaction Control Statements.. Session Control Statements.. System Control Statement.. Embedded SQL Statements.. Which are 3 different types of SQL statements that you can execute?Types of SQL Statements. DML (DATA MANIPULATION LANGUAGE). DDL (DATA DEFINITION LANGUAGE). DCL (DATA CONTROL LANGUAGE). TCL (TRANSACTION CONTROL LANGUAGE). Which of the following SQL statement is the correct way to create a database?Create Database
The SQL statement CREATE is used to create the database and table structures.
Which of the following SQL statement is correct?1 Answer. The correct answer to the question “Which of the SQL statements is correct” is option (b). SELECT Username, Password FROM Users. And all the other options are incorrect.
|