SQL stands for Structured Query Language. A query language is a kind of programming language that's designed to facilitate retrieving specific information from databases, and that's exactly what SQL does.
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.
SQL commands are the instructions used to communicate with a database to perform tasks, functions, and queries with data. SQL commands can be used to search the database and to do other functions like creating tables, adding data to tables, modifying data, and dropping tables
MySQL queries are SQL functions that help us to access a particular set of records from a database table. We can request any information or data from the database using the clauses or let’s say SQL statements.
A query is a question or inquiry to a set of data. We use SQL, or Structured Query Language, to retrieve data from databases. When we build the structure we are pulling data from tables and fields. The fields are columns in the database table while the actual data makes up the rows.
An SQL key is either a single column (or attribute) or a group of columns that can uniquely identify rows (or tuples) in a table. SQL keys ensure that there are no rows with duplicate information.
Joins in SQL can be of four different types, subjected to the outcome expected by combining records from two or more tables by making use of the common columns from tables involved in the Join function. Inner Join is used to get records with same values In both tables, Left Join is used to get all records from Left side table and only matching values from right table and Right Join is used to get all records from Right table and only matching records in left table. finally Full Join to get all the records from both tables irrespective of matching records.
CONGRATULATION YOU HAVE COMPLETED THIS COURSES IF YOU STUDY AT THIS POINT. CHECK OUT OUR INDUSTRY RECOGNIZED CERTIFICATION COURSES
0
Creating Various Types of Tables in SQL Server 2012
In this article, I am going to give a quick overview of the various Types of tables in SQL Server. In SQL we can create various types of tables (User table, Temporary table, Global table etc.) which can be used for various purposes in SQL Server. I will try to highlight all the major tables in this article. So let’s have a look at a practical example of how to create various types of tables in SQL Server. The example is developed in SQL Server 2012 using the SQL Server Management Studio.
The following are the various types of tables in SQL Server.
1. User Tables (Regular Tables)
Regular tables are the most important tables. They contain data for later use. Regular tables are stored in the hard drive. If you want to delete these tables from hard drive, you can use a drop command in SQL Server. The following is a sample of creating a regular table:
CreateTABLE [dbo].[Employee]
(
[EmpID] [int] NULL,
[EmpName] [varchar](30) NULL,
[EmpSalary] [int] NULL
)
Now press F5 to execute it.
Output
You can see this table from: Object Explorer -> Database – Tables
2. Local Temporary Tables
Local temporary tables are the tables stored in tempdb.Local temporary tables are temporary tables that are available only to the session that created them. These tables are automatically destroyed at the termination of the procedure or session. They are specified with the prefix #,
For example #table_name and these temp tables can be created with the same name in multiple windows.
Creating local temporary table
The following is a sample of creating a local temporary table:
createtable #table_name
(
column_name varchar(20),
column_no int
)
3. Global Temporary Tables
Global temporary tables are also stored in tempdb.Global temporary tables are temporary tables that are available to all sessions and all users. They are dropped automatically when the last session using the temporary table has completed. They are specified with the prefix #, for example ##table_name.
Creating Global Temporary Table
The following is a sample of creating a Global Temporary table:
createtable ##GlobalTemporaryTable
(
column_name varchar(20),
column_no int
)
Both tables are stored in the tempdb system database.
Storage Location of a Temporary Table
Temporary tables are stored inside the Temporary Folder of tempdb. Whenever we create a temporary table, it goes to the Temporary folder of the tempdb database. tempdb -> temporary tables.
Temporary Tables VS Regular Table
A Temporary table differs in the following two ways from regular tables:
Each temporary table is implicitly dropped by the system.
Each temporary table is stored in the tempdb system database. The table variable doesn’t.
4. Creation of Table with the Help of Another Table
Suppose you create a table named employee table (like the above table). The following is the sample data for the employee Table:
Now we want to create a table which is exactly the copy of a given table; then we can also use the following SQL Query:
SELECT * into studentCopy FROM employee
Now using a select statement with the table named studentCopy:
SELECT * FROM studentCopy
Output
5. Table Variable
Table variables are alternatives to temporary tables which store a set of records. The syntax of a table variable is shown below: