SQL

What are the different SQL Syntax?

SQL is defined by distinctive set of rules and guidelines called Syntax. There can be one or more than one tables in a single database. Each table is indentified by a unique name (e.g. “Employees” or “students”). Each table contains various records (rows) and fields (columns) with respective data.   SQL Statements Most of the actions you need to perform on a database are done with SQL statements. The important

How to select a single Database in SQL?

In order to select a single database from the multiple databases in your SQL Schema and to start your operation, make use of the SQL USE Statement. The USE statement is used to select any existing dataset from the list of databases.   Basic syntax of USE statement is as follows: USE DatabaseName; Kindly note that the Database Name should always be unique in RDBMS.   Example: Check the list

How to write a Select Statement in SQL?

In order to fetch or retrieve data from a table and display the data in the form of resultant table, SQL Select Statement is used. The resultant tables are known as result-sets.   Syntax: The syntax of SELECT statement is: Select column_name1, column_name2, …, column_namen From table_name; And it can also be written as follows:   Select * From table_name;   In the above syntax, column_name1, column_name2 are the fields

How to use a Primary Key in SQL?

The PRIMARY KEY is a set of columns that uniquely identifies each record in a database table. Primary keys must contain unique values and cannot contain NULL values. Most tables should have a primary key, and each table can have only ONE primary key. SQL PRIMARY KEY Constraint on CREATE TABLE The following SQL creates a PRIMARY KEY on the "roll_no" column when the "Students" table is created:   Create

How to use an Order-By Clause in SQL?

In order to sort the result-set of many columns in ascending or descending order, the SQL ORDER BY clause is used.   The records are by default sort in ascending order when used ORDER BY keyword. To sort the data in the descending order, make use of the DESC keyword.   By sorting the data, make sure that the column you want to sort is present in that respective column-list.   The

What are different types of SQL Operators?

What is an Operator in SQL? An operator is a reserved word or a character used primarily in an SQL statement's WHERE clause to perform operation(s), such as comparisons and arithmetic operations. Operators are used to specify conditions in an SQL statement and to serve as conjunctions for multiple conditions in a statement. ·         Arithmetic operators ·         Comparison operators ·         Logical operators ·         Operators used to negate conditions   SQL

What is a Null Value in SQL?

In order to represent a missing or unknown value, the SQL NULL is the term used. A NULL value is a value in a table where a column (field) that appears to be blank. By default, the table takes NULL values. It is essential to identify that a NULL value is different than a zero value or a field that contains spaces. Let us now understand the IS NULL and IS NOT

How to make use of the SQL Like Clause?

If you want to search a particular pattern in a specified column for a table, a LIKE operator is used in a WHERE Clause. There are two symbols used in combination with the LIKE operator: ·         The underscore (_) ·         The percent sign (%) The underscore symbolizes a single number or character. The percent sign symbolizes zero, one, or multiple characters. These symbols can also be used in combinations with

What is a Group By in SQL?

In order to arrange the identical data into groups, the SQL GROUP BY clause is used in combination with the SELECT statement. The GROUP BY clause is used in collaboration with the aggregate functions to group one or more columns of the table. We can say that the GROUP BY clause is followed after the WHERE clause in a SELECT statement and is followed by the ORDER BY clause.   Syntax of

How to Drop a Table in SQL?

In order to delete or remove a table all the information related to that particular table such as data, indexes, constraints, triggers and permission specification, make use of the SQL DROP TABLE statement.   NOTE: While deleting the table, you have to be extra careful as deleting the table will result in loss of the entire data associated with that table forever.   Syntax of DROP TABLE statement is as follows: Drop Table