SQL Example, Codes and Tutorials

SQL stands for Structured Query Language. It is easy and allows us to create a database.

SQL Example, Codes and Tutorials

SQL Example, Codes and Tutorials

     

SQL Tutorials:
Collection of SQL tutorials for beginners and advance programmers. We have developed many tutorials and examples on SQL. Here you will find everything to get started with SQL and then learn the advance concepts of SQL. The Standard Query Language or SQL for short is standard language to interact with the database. SQL allows you to create, delete, update tables and data stored in the table. SQL provides everything to help the programmer to interact with database and develop enterprise applications.

In this tutorial you will learn how to you user SQL to interact with database. We have used MySQL database to make the process simple. You can easily download MySQL from mysql.com and install on your machine to experiment and learn the SQL concepts.

SQL Beginner
The Tutorial brings  a unique introduction on SQL for beginners, who want to learn and understand SQL.
SQL: A brief Introduction
SQL stands for Structured Query Language. It is easy and allows us to create a database.
SQL Date Examples
Trigger
SQL Join Mysql Alter
Online Mysql Training SQL Functions
MySql Example MySql Remove
MySql Table MySql Update
MySql Injection

General SQL Concepts:

Following articles/examples are used frequently while interacting with the databases. Learn SQL concepts by reading the following tutorials.

  1. Data Normalization
    In this section we will learn about the concepts of data normalization. T
    he most important thing in database designing is to make sure that the data get properly distributed among the tables. 
     
  2. Create a database
    we can create a database by using the Database name. In SQL the key word 'Show databases' finds the existing databases. You may create your own or use an existing one after that create connection with database.
     
  3. The INSERT INTO Statement
    To insert records into a table, use the key word insert into 'table name',  just write a list of column names separated by commas, followed by a closing parenthesis then using keyword values, write the list of values enclosed in parenthesis.
     
  4. The UPDATE Statement
    The UPDATE statement is used to modify the data in the database table in a specified manner. In the syntax of update statement the keyword 'set' is used to assign a new value to a selected column. The statement is accomplished by a where clause.
     
  5. The DELETE Statement
    The DELETE statement is used to delete rows in a table. database will update that is why deletion and insertion of data will be done.
      
  6. The SELECT Statement
    SELECT key word is used to select data from a table. The tabular result is stored in a result set. SELECT column_name give the path FROM table_name.
     

  7. The WHERE Clause
    WHERE clause is used with the SELECT keyword. 'Where' is a clause which is used for searching the data with a particular condition. 

  8. The Aggregate Functions
    In this section we are going to illustrate aggregate function, with the help of which we can use many arithmetic operation like average, count, maximum and many more in SQL.
      
  9. SQL % Wildcards
    SQL wildcards used for  searching one or more characters from data in a database.
     
  10. SQL UNIQUE Constraint
    The UNIQUE constraint uniquely identifies each record in a database table.
      
  11. SQL UNION ALL Operator
    The SQL UNION ALL Operator is used to list all records from  two or more select statements. 
  12. SQL UNION Operator
    The UNION operator is used to combine the result-set of two or more SELECT statements.
      
  13. SQL Right JOIN
    The RIGHT JOIN keyword returns you  all rows from the right table (table_name1), incase if there are no matches in the left table (table_name2).
      
  14. SQL IN Operator
      
    SQL IN Operator helps you to specify multiple values in a WHERE Clause.
      
  15. SQl Date
    The SQL Date is used when you are working with dates. This include the format of data ,the insert value matches the format of the data column  in the database.
     
  16. SQL Create View
     
    A View is a imaginary and virtual table in SQL. In SQL, a view is defined  as a virtual table outcome as a result of an SQL statement. 
     
  17. SQL BETWEEN Operator
    The SQL Between Operator works where you want to select a range of data between two values.  
      
  18. SQL as Keyword
    The SQL Key word used in SQL are createTable,Insert into,select,delete,update,etc.
      
  19. SQL And Statement
     
    The SQL AND operator is used to show you the filter records based upon conditions
     
  20. SQL AND Operators
    The AND operator displays records if both conditions are true.
     
  21. SQL AND Like Operator
    The SQL AND Like Operator work with WHERE clause to find and search  for a specified pattern in a column of table. 
     
  22. SQL Alter View
     
    In SQL Alter View is used to modify a previous created view.
     
  23. SQL Alter Table Name
    SQL Alter Table Name is used to change or modify  name of the existing table.
     
  24. SQL Alter Column type
    Alter Column type in SQL is used to change or recreate the data type of existing column.  
        
  25. SQL Alter Column Size
    Alter Column Size modify the Column Size. The SQL Alter Column Size is used when you want to change the data type size. 
     
  26. SQL Alter Column Not Null
    The Column Not Null in SQL is used when you want the column should not be null in your table.
      
  27. SQL Alter Column Name
    Alter Column Name in SQL is used to change or modify the name of column in a table. 
       
  28. SQL Alter Column Default Value
    Alter Column Default Value in  SQL Server is used with Create Table Statement. The default value will be set as per specified column.
      
  29. SQL Alter Column
    SQL Alter Column modifies the existing table and add a column.
      
  30. SQL Alias
    SQL Alias is the another name given to the existing table and the column.
      
  31. SQL Add Column Position
    SQL Add Column Position is used to add the column at the specific position.
        
  32. SQL Add Column Int
    SQL Add Column Int is used to add new column, whose field data type is integer.
      
  33. SQL add column default value
    Add a Column default value is used in SQL, When create statement Query is performed in SQL .Usually, the default value is given to the column ,when no value is inserted to the column . 
      
  34. SQL Add Column
     
    SQL Add Column is used to add a new column in the existing table.
      
  35. SQL _ Wildcards
    SQL wildcards used for  searching one or more characters from data in a database.
     
  36. LIKE Operator
    The LIKE operator is used for searching  a specified pattern in the column.
     
  37. SQL SELECT DISTINCT Statement
    In this example we will show you the usage of Distinct clause with the select statement.  The SQL Distinct clause is used with the Select statement to show all unique records from database.
     
  38. SQL LEFT JOIN
    The LEFT JOIN keyword retrieve all rows from the left table (table_name1), even if there are no matches in the right table (table_name2).
      
  39. SQL NOT NULL Constraint
    The NOT NULL constraint enforces a column to NOT accept NULL values.
      
  40. SQL ORDER BY
    The ORDER BY keyword is used to sort the table result set by a specified column. If you want to sort the records in ascending order,  you can use the ASC keyword.
      
  41. SQL OR Operators
    The OR operator displays records if any of the conditions is true.
      
  42. SQL PRIMARY KEY Constraint
    The PRIMARY KEY constraint is used to uniquely identifies each record in a database table.
      
  43. SQL INNER Joins
    The JOIN keyword is used in SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables.
      
  44. SQL Alias
    In SQL we can give a table or column another name by using an Alias.  
  45. Using while loop to loop through a cursor
    Cursor in SQL is used to define a set of data rows and perform complex logic on each row by row basis.
     
  46. Variables Scope in SQL Procedure
     
    Variable Scope in SQL Procedure is used to define the scope of a variable used in SQL.
      
  47. Use DEFAULT Statement in Procedure
     
    The Tutorial illustrate an example 'Use DEFAULT Statement in Procedure'.
     
  48. Use DECLARE Statement in Procedure
      
    Use DECLARE Statement in Procedure is used to define variable and its data type.
      
  49. Until Loop In a Procedure
      
    Until Loop In a Procedure is used to execute a set of statements repeatedly until a certain condition is reached.
      
  50. SQL IN Parameters
     
    A parameter is a placeholder that accept a user-defined value, whenever stored procedure is executed.
      
  51. SQL Out Parameter
     
    SQL Out Parameter allows the stored procedure to the pass data value  back to the invoker.
     
  52. SQL Bulk Insert Example
     
    SQL Bulk Insert Example is used to insert a bulk record to the table.
      
  53. SQL Backup Table
    The Select Statement is used to create backup copies of tables.
      
  54. SQL Backup query with where statement
    The Where Clause in Backup query return you the restricted records into stu_tab_ Backup specified in table 'Stu_Table'.
     
  55. Simple Procedure to display Hello World
     
    Procedure is a set of SQL statement enclosed in 'BEGIN' and 'END' statement and executed under one name.
     
  56. Insert Data From File
    Insert Data From File is  used to insert data from file.  
  57. Use HANDLER Statement in Cursors
     
    Use HANDLER Statement in Cursor is used to define a set of data rows where we perform operation on  a row by row basis.
     
  58. Close Cursors in SQL
     
    Close Cursor is used to close the cursor temporary when it is not required.
     
  59. Declare Cursors in SQL
    Declare Cursors in SQL is used to define cursor and its characteristics.
     
  60. Creating Cursors in SQL
     
    Creating Cursor in SQL is used to create a cursor in SQL.  
  61. Close Cursors in SQL
     
    Close Cursors is used to close the Cursor temporary, when the open cursor is not required.
      
  62. Use if statement with LOOP statement
      
    Conditional if statements  in SQL are used to perform different actions based on different conditions.
      
  63. SQL UCASE Function
     The UCASE function help you to converts the fields value into the uppercase.  

  64. SQL Simple LOOP
     
    Simple LOOP in Procedure is a series of statement that are executed repeatedly until it push the flow of control to outside of the loop.
     
  65. SQL ROUND Function
    Round Function in SQL is used to round a numeric field to the nearest decimals specified.
      
  66. SQL NOW() Function
    NOW ( ) Function provides you the current date and time according to your computer's system date and time. 
      
  67. SQL Length Function
    Length Function in SQL is used to return the length of a column, string or variable in bytes or characters.
      
  68. SQL LCASE Function
    The LCASE function converts the fields value into the lowercase.
      
  69. SQL HAVING Clause
    Having clause is used with the select clause to specify a search condition for a group or aggregate.
      
  70. SQL Between Timestamp
    A timestamp is used to catch the dates and times.
       
  71. SQL Between Datetime
    The Date Time structure tell you an instant in time, hold both date and a time. 
      
  72. SQL Between Date
    The Tutorial help you to understand SQL Between Date.
      
  73. SQL Begin End
    Begin End in SQL include the set of select statement executed within these blocks.
     
  74. SQL Avg Group By
    SQL Avg Group By helps you to find out average value of numeric field in a table.
      
  75. SQL Average Count
    Average Count in SQL is used to count the aggregate sum of any field in a table.
      
  76. SQL Alter Table Primary Key
    Alter a Table Primary Key in SQL modifies the existing table and adds a primary key. 
     
  77. SQL Alter Table Add Multiple Columns
    Alter Table Add Multiple Columns in SQL modifies the table and add columns to the existing table. 
      
  78. SQL Aggregate Sum
    The SQL Aggregate Sum Function is a part of Aggregate Function that is used to compute sum of the numeric field in a table.
        
  79. SQL Aggregate Max
    SQL Aggregate Max is used to find the highest value of the column in a table. 
      
  80. SQL Aggregate Functions Group By
    SQL Aggregate Functions Group By return the aggregate functions (like SUM) of the different numeric field for each individual group of column values.
     
  81. SQL Aggregate Functions First
    SQL Aggregate Function First, that performs calculation of data. The SQL aggregate function retrieve a single value, by calculate from values in a column.
     
  82. SQL Aggregate Functions In Where Clause
    SQL Aggregate Function In Where Clause return the maximum conditional value of the record from a table.
      
  83. SQL Aggregate Concatenate
    SQL Aggregate Concatenate provides you a concatenated record of the  field based on the conditional operator WHERE clause.
     
  84. Drop Table
    Drop Table in SQL get rid of an object or table from the database.
       
  85. Drop Index
    Drop Index is used to remove one or more indexes from the current database.
       
  86. Create After Update Trigger in SQL
     
    After Trigger in SQL is fired before update the column in the table.
      
  87. Create a Simple Procedure
    Simple Procedure is a set of SQL statement which are executed under one name.
       
  88. Create Delete Trigger in SQL
     
    Create Delete Trigger in SQL fire this trigger before the DELETE operation is executed.
     
  89. Create Before Update Trigger in SQL
     
    Create Before Update Trigger in SQL is used in SQL, if a trigger monitoring for changes to a column of the table.
     
  90. Create Before Insert Trigger in SQL
    The Create Before Insert Trigger in SQL fires the trigger before we insert the value into the table.
     
  91. Create After Insert Trigger in SQL
    Create a Trigger is a special kind of stored procedure, that fires when we perform modification on the specific data on the specified table.
     
  92. Call Procedure
     Procedure is a set of SQL statement that perform a logical unit and  task.
      
  93. Backup selected records into txt file
    Backup selected records into txt file is used to copies the selected records or rows from a table into text file.
     
  94. Backup Into txt File
     
    Backup Into txt File is used to put the backup file from a  table into a text File.
     
  95. Backup File With Separator 

    Backup File With Separator in SQL  is used to indicate line and record separator.