Tag Archives: SQL Examples

Learn to Code SQL Example – SQL | CREATE

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | CREATE There are two CREATE statements available in SQL: CREATE DATABASE CREATE TABLE   CREATE DATABASE A Database is defined as a structured set of data. So, in SQL the very first step to store the data in a well structured manner is to create …

Learn to Code SQL Example – SQL | ALTER (RENAME)

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | ALTER (RENAME) Sometimes we may want to rename our table to give it a more relevant name. For this purpose we can use ALTER TABLE to rename the name of table. *Syntax may vary in different databases. Syntax(Oracle,MySQL,MariaDB): ALTER TABLE table_name RENAME TO new_table_name; Columns …

Learn to Code SQL Example – SQL | DROP, TRUNCATE

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | DROP, TRUNCATE DROP DROP is used to delete a whole database or just a table.The DROP statement destroys the objects like an existing database, table, index, or view. A DROP statement in SQL removes a component from a relational database management system (RDBMS). Syntax: …

Learn to Code SQL Example – SQL | Create Table

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | Create Table Extension SQL provides an extension for CREATE TABLE clause that creates a new table with the same schema of some existing table in the database. It is used to store the result of complex queries temporarily in a new table. The new table …

Learn to Code SQL Example – SQL | SELECT Query

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | SELECT Query Select is the most commonly used statement in SQL. The SELECT Statement in SQL is used to retrieve or fetch data from a database. We can fetch either the entire table or according to some specified rules. The data returned is …

Learn to Code SQL Example – SQL | UNIQUE Constraint

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | UNIQUE Constraint Unique constraint in SQL is used to check whether the sub query has duplicate tuples in it’s result. It returns a boolean value indicating the presence/absence of duplicate tuples. Unique construct returns true only if the sub query has no duplicate …

Learn to Code SQL Example – SQL | Distinct Clause

(SQL Example for Citizen Data Scientist & Business Analyst) SQL | Distinct Clause The distinct keyword is used in conjunction with select keyword. It is helpful when there is need of avoiding the duplicate values present in any specific columns/table. When we use distinct keyword only the unique values are fetched. Basic Syntax: SELECT DISTINCT column1,column2 …

Learn to Code SQL Example – SQL | Case Statement

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | Case Statement Control statements form the heart of most languages since they control the execution of other sets of statements. These are found in SQL too, and should be exploited for uses such as query filtering and query optimization through careful selection of …

Learn to Code SQL Example – SQL | WHERE Clause

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | WHERE Clause WHERE keyword is used for fetching filtered data in a result set. It is used to fetch data according to a particular criteria. WHERE keyword can also be used to filter data by matching patterns.   Basic Syntax: SELECT column1,column2 FROM table_name WHERE …

Learn to Code SQL Example – SQL | AND and OR operators

(SQL Example for Citizen Data Scientist & Business Analyst)   SQL | AND and OR operators In SQL, the AND & OR operators are used for filtering the data and getting precise result based on conditions. The AND and OR operators are used with the WHERE clause. These two operators are called conjunctive operators. AND Operator …