SQL TUTORIAL
SQL ALIAS
This tutorial shows you how to use SQL alias including column and table aliases to make your queries shorter and more understandable.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Oracle Query Performance Tuning | 2001/01/23 3:21:17 | 19 | 2001/02/26 17:6:36 |
2 | MySql Database Internals | 2003/06/13 19:23:12 | 3 | 2003/07/19 16:41:16 |
3 | SQL Puzzles & Answers | 2008/04/23 19:13:29 | 6 | 2008/04/28 21:20:16 |
4 | The Database Language SQL | 2002/07/22 20:5:26 | 13 | 2002/08/26 3:55:27 |
SQL ALTER TABLE
The ALTER TABLE Statement. The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Hanumanthan | Male | 24 | Chennai |
2 | Siva Kumar | Male | 34 | Delhi |
3 | Nirmala | Female | 21 | Aruppukoottai |
4 | Chandra | Female | 33 | Pune |
SQL AND OR
The AND operator can be used to join two or more conditions in the WHERE clause. Both sides of the AND condition must be true in order for the condition to be executed.
sql greater than and less than
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Sql Server Interview Questions | 2006/07/19 17:26:40 | 14 | 2006/08/28 11:29:27 |
2 | Pro Oracle Administration | 1995/08/13 22:50:52 | 1 | 1995/09/24 10:15:46 |
3 | SQL Functions Reference | 2002/03/21 21:18:4 | 19 | 2002/03/27 11:5:16 |
4 | Programming With Sql Server T-Sql | 1995/08/26 17:47:47 | 15 | 1995/08/28 1:6:23 |
SQL AUTO INCREMENT
SQL Tutorial-SQL Autoincrement is used to increment value of a field automatically while inserting new record in table.It can be used for integer field only.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | SQL Made Simple... By Examples | 2005/03/18 9:13:15 | 5 | 2005/04/26 12:27:4 |
2 | Pro Full-text Search In SQL Server | 2005/10/14 20:54:54 | 15 | 2005/11/21 22:51:57 |
3 | MySql Database Internals | 2011/05/24 11:41:9 | 8 | 2011/06/27 4:33:47 |
4 | The Practical SQL Handbook | 2001/03/22 14:24:21 | 16 | 2001/03/27 1:21:29 |
SQL BETWEEN
Determines whether the value of an expression falls within a specified range of values. You can use this operator within SQL statements.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Oracle All-in-One For Dummies | 2007/06/24 5:15:56 | 3 | 2007/07/27 9:39:59 |
2 | Oracle Database 11G New Features | 2010/06/21 22:37:45 | 5 | 2010/07/26 7:9:13 |
3 | Beginning SQL Queries | 2000/10/15 12:14:55 | 15 | 2000/10/17 22:55:47 |
4 | Mastering Oracle SQL | 2006/03/24 12:16:2 | 17 | 2006/04/28 12:55:56 |
SQL CHECK
SQL CREATE TABLE with constraint to exclude NULL value; SQL CREATE TABLE to check unique value; SQL CREATE TABLE to check.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Geetha | Female | 23 | Nasik |
2 | Bala Murugan | Female | 29 | Trichy |
3 | Ranjani Mai | Female | 22 | Emaneshwaram |
4 | Pandurengan | Female | 30 | Nasik |
SQL CREATE TABLE
This SQL Server tutorial explains how to use the CREATE TABLE statement in SQL Server (Transact-SQL) with syntax and examples.
sql server create table as select
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Ramanathan | Male | 28 | Mumbai |
2 | Devi Mai | Female | 24 | Madurai |
3 | Keshavan | Female | 27 | Hyderbhad |
4 | Keshavan | Female | 30 | Paramakudi |
SQL DEFAULT
The DEFAULT value clause in a data type specification indicates a default value ... MySQL handles the column according to the SQL mode in effect at the time:.
sql server create table default value
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | SQL in a Nutshell | 2006/03/18 6:31:3 | 10 | 2006/04/23 12:2:35 |
2 | Oracle Cookbook | 2003/02/11 17:47:47 | 18 | 2003/03/25 2:26:10 |
3 | Head First SQL Brain On SQL | 2000/07/21 23:15:14 | 7 | 2000/07/24 22:39:27 |
4 | Simply SQL | 2002/07/19 14:42:25 | 7 | 2002/07/23 18:55:17 |
SQL DELETE
The following example shows the Transact-SQL extension used to delete records from a base table that is based on a join or correlated subquery.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | SQL Pocket Guide | 2009/06/24 2:34:44 | 8 | 2009/07/26 9:13:30 |
2 | Troubleshooting SQL Server | 2007/08/19 19:31:38 | 8 | 2007/09/28 11:43:25 |
3 | SQL Success - Database Programming Proficiency | 2006/02/12 2:47:1 | 14 | 2006/03/23 17:2:27 |
4 | The Database Language SQL | 2007/08/21 12:33:6 | 8 | 2007/08/26 5:30:44 |
SQL DISTINCT
The DISTINCT clause in your result set will listed after the DISTINCT keyword, and therefore returns unique combinations.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Geetha | Male | 23 | Pune |
2 | Varshini Kutty | Male | 26 | Nasik |
3 | Pandurengan | Female | 20 | Mysore |
4 | Bala Murugan | Male | 28 | Bangalore |
SQL FOREIGN KEY
SQL FOREIGN KEY Constraint. A FOREIGN KEY in one table points to a PRIMARY KEY in another table.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Dharan | Male | 26 | Mysore |
2 | Hanumanthan | Male | 34 | Mumbai |
3 | Dharan | Female | 28 | Ramnad |
4 | Padmavathi | Male | 28 | Emaneshwaram |
SQL FULL JOIN
The FULL OUTER JOIN keyword returns all rows from the left table (table1) and from the right table (table2).
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Sakunthala | Female | 33 | Emaneshwaram |
2 | Balan | Male | 32 | Trichy |
3 | Vinoth Kumar | Female | 30 | Mumbai |
4 | Geetha | Male | 27 | Bangalore |
SQL GROUP BY
The GROUP BY clause will gather all of the rows together that contain data in the specified column(s) and will allow aggregate functions to be performed on the grouped data.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | PowerShell for SQL Server Essentials | 1997/08/25 17:42:51 | 16 | 1997/08/27 9:57:18 |
2 | Pro Full-text Search In SQL Server | 1999/04/21 20:4:9 | 13 | 1999/04/24 4:49:51 |
3 | Transact SQL Cookbook | 2004/06/16 19:20:35 | 6 | 2004/07/23 3:30:52 |
4 | SQL Fundamentals | 2011/01/18 7:17:36 | 4 | 2011/01/24 21:55:54 |
SQL HAVING
The HAVING clause was added to SQL because the WHERE keyword could not be used with ... HAVING aggregate-function(column-name) operator value.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Sql Server Transaction Log Management | 1999/01/15 12:45:33 | 13 | 1999/01/18 7:10:13 |
2 | Oracle Database 11G New Features | 2003/10/13 22:46:58 | 3 | 2003/10/21 13:6:6 |
3 | How to Write Accurate SQL Code | 2009/01/23 21:52:22 | 13 | 2009/01/28 21:53:52 |
4 | Learing Oracle SQL & Pl/sql | 1999/01/20 5:9:17 | 5 | 1999/02/26 8:30:23 |
SQL IN
The IN conditional operator is really a set membership test operator.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Ranjani Mai | Male | 31 | Kumbakonam |
2 | Nirmala | Male | 23 | Mysore |
3 | Ramanathan | Male | 24 | Hyderbhad |
4 | Harish Karthik | Male | 30 | Paramakudi |
SQL INNER JOIN
Summary: in this tutorial, we will show you how to use the SQL INNER JOIN clause to query data from two or more tables.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Devi Mai | Female | 26 | Paramakudi |
2 | Harish Karthik | Female | 34 | Madurai |
3 | Ramanathan | Female | 26 | Chennai |
4 | Balan | Female | 30 | Mysore |
SQL INSERT INTO
You must have INSERT privilege on a table in order to insert into it, and ... INSERT conforms to the SQL standard, except that the RETURNING clause is a
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Mastering Oracle SQL | 1998/08/26 14:2:40 | 2 | 1998/09/28 9:31:48 |
2 | Oracle Cookbook | 1996/07/18 17:56:2 | 16 | 1996/07/25 7:24:4 |
3 | Postgresql Official Documentation | 2010/08/13 9:53:40 | 6 | 2010/08/16 22:37:33 |
4 | SQL Programming & Database Design | 1996/05/15 7:35:40 | 14 | 1996/05/18 14:30:42 |
SQL INSERT INTO SELECT
In the following example the INSERT statement inserts into a separate table some of the SELECT statement is to insert data from a source outside SQL Server.
microsoft sql insert into select
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Oracle Interview Questions | 2001/01/15 10:4:22 | 19 | 2001/01/27 6:43:44 |
2 | Troubleshooting SQL Server | 2001/02/26 19:39:51 | 6 | 2001/02/28 16:40:19 |
3 | The Complete Guide to Oracle | 1999/03/20 10:25:27 | 12 | 1999/04/25 17:59:33 |
4 | SQL Server: The Complete Reference | 2000/06/17 5:27:21 | 15 | 2000/07/22 2:6:11 |
SQL LEFT JOIN
SQL server LEFT outer JOIN clause allows you to select data from two or more tables. Our MySQL tutorials are practical and easy-to-follow, with SQL script and examples.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Hanumanthan | Male | 31 | Madurai |
2 | Sakunthala | Female | 20 | Madurai |
3 | Dharan | Female | 22 | Hyderbhad |
4 | Chandra | Female | 28 | Hyderbhad |
SQL LIKE
The LIKE conditions specify a test involving pattern matching. Whereas the equality operator (=) exactly matches one character value to another, the LIKE conditions match a portion of one character value.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Ranjani Mai | Female | 26 | Kumbakonam |
2 | Devi Mai | Male | 31 | Chennai |
3 | Dharan | Female | 24 | Chennai |
4 | Rishi Keshan | Male | 28 | Delhi |
SQL NOT NULL
Adds a not-null constraint to an existing table.
oracle add not null constraint
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Pro Oracle SQL | 1995/02/23 6:54:28 | 15 | 1995/03/28 3:29:14 |
2 | SQL and PL/SQL for Oracle 10g Black Book | 2001/08/22 19:19:10 | 4 | 2001/09/28 18:12:23 |
3 | Programming with T-SQL for Beginners | 2008/02/17 13:8:43 | 11 | 2008/02/20 14:2:34 |
4 | PowerShell for SQL Server Essentials | 1997/01/16 11:49:56 | 8 | 1997/02/27 7:42:28 |
SQL ORDER BY
SQL ORDER BY Clause - Learn SQL (Structured Programming Language) in simple and easy steps starting from basics to advanced concepts.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | SQL For Microsoft Access | 2010/09/25 20:31:11 | 1 | 2010/10/28 17:4:4 |
2 | Complete Guide To No-SQL | 1995/04/21 4:32:16 | 16 | 1995/05/28 11:42:44 |
3 | Oracle 11g PL/SQL Programming | 2005/09/17 6:22:28 | 4 | 2005/10/28 5:42:54 |
4 | Understanding the New SQL | 2001/03/21 13:37:47 | 12 | 2001/03/28 16:55:54 |
SQL PRIMARY KEY
SQL PRIMARY KEY apply on column(s) for a uniquely identifies each record in the table. Simple Key vs Composite Key.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Oracle Database 11G New Features | 2009/06/12 12:8:52 | 6 | 2009/07/27 8:39:53 |
2 | MySql Interview Questions | 2006/09/20 12:45:22 | 9 | 2006/09/27 4:13:6 |
3 | Oracle Cookbook | 2002/05/16 23:36:14 | 16 | 2002/05/27 19:22:15 |
4 | Securing SQL Server | 2006/05/26 15:25:39 | 16 | 2006/05/28 2:8:20 |
SQL RIGHT JOIN
This lesson of the SQL tutorial for data analysis includes code and examples for SQL RIGHT JOIN. RIGHT JOIN allows you to return unmatched rows in one table.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Pro Sql Server 2008 Administration | 2007/02/14 3:44:35 | 12 | 2007/03/27 23:15:43 |
2 | SQL Server 2012 Black Book | 2001/04/18 20:57:28 | 2 | 2001/04/27 20:43:27 |
3 | Building A Data Warehouse In SQL Server | 1999/01/15 16:50:59 | 9 | 1999/02/25 11:3:35 |
4 | The Complete Guide to MySql | 2010/07/15 17:13:31 | 1 | 2010/07/20 11:20:46 |
SQL SELECT
SELECT can also be used to retrieve rows computed without reference to any table. In general, clauses used must be given in exactly the order shown in the syntax description.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Sakunthala | Female | 29 | Delhi |
2 | Siva Kumar | Female | 26 | Madurai |
3 | Vinoth Kumar | Female | 32 | Bangalore |
4 | Hari Krishnan | Female | 25 | Hyderbhad |
SQL TOP
It demonstrates how Oracle limits the number of records selected. The top-N query in Oracle is not as easy to create as those in MS SQL Server (TOP n keyword).
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Simply Oracle | 2006/03/26 13:15:7 | 10 | 2006/04/28 1:38:42 |
2 | Microsoft SQL Server 2012 | 2001/09/23 17:4:28 | 2 | 2001/09/26 2:25:13 |
3 | Pro Sql Server 2008 Policy based management | 2008/07/17 15:27:11 | 13 | 2008/08/28 18:19:44 |
4 | Securing MySql | 2001/06/15 22:4:21 | 10 | 2001/07/18 17:5:1 |
SQL UNION
You can combine multiple queries using the set operators UNION , UNION ALL , INTERSECT, and MINUS . All set operators have equal precedence.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | SQL Pocket Guide | 2005/10/13 4:51:49 | 15 | 2005/11/15 15:14:32 |
2 | Sql Server T-sql By Example | 1995/04/22 2:17:34 | 14 | 1995/04/25 18:55:34 |
3 | Introduction to SQL and PL/SQL | 2006/03/17 8:41:56 | 6 | 2006/03/27 9:59:5 |
4 | Simply SQL | 2005/08/20 1:51:13 | 14 | 2005/08/23 3:18:26 |
SQL UNIQUE
SQL - Syntax. ... The UNIQUE Constraint prevents two records from having identical values in a particular column.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Geetha | Male | 30 | Chennai |
2 | Bala Murugan | Male | 27 | Emaneshwaram |
3 | Sakunthala | Female | 21 | Ramnad |
4 | Bala Murugan | Male | 24 | Nasik |
SQL UPDATE
An UPDATE statement is used to modify a subset of the values stored in zero or more rows of the database table identified by the qualified-table-name specified
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Nirmala | Female | 34 | Nasik |
2 | Devi Mai | Female | 23 | Hyderbhad |
3 | Dharan | Female | 26 | Kumbakonam |
4 | Sakunthala | Male | 23 | Kumbakonam |
SQL WHERE
A WHERE clause in SQL specifies that a SQL Data Manipulation Language (DML) statement should only affect rows that meet specified criteria. The criteria are expressed in the form of predicates.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | SQL Fundamentals | 2003/07/24 5:8:55 | 4 | 2003/08/28 18:35:8 |
2 | SQL in a Nutshell | 2005/10/11 20:26:37 | 8 | 2005/10/20 13:14:31 |
3 | MySql Concurrency | 2006/01/22 19:42:14 | 18 | 2006/02/28 10:43:45 |
4 | PowerShell for SQL Server Essentials | 2002/02/16 3:18:36 | 4 | 2002/03/26 9:18:46 |