Posts

Showing posts from July, 2020

SQL Joins

SQL JOINS:-  JOIN means to combine something. In case of SQL join clause is used to combine rows from two or more table, based on a related column between them. IMPORTANCE OF JOIN:- If you want to combine two or more table the SQL JOIN is used. If you want to access more than one table through a SELECT statement. The joining of two or more tables is based on common filed between them. TYPES OF JOIN:- INNER JOIN:- INNER JOIN returns records that have matching values in both the table. LEFT(OUTER) JOIN:- This join returns all records from the left table , and the matched record from the right table. RIGHT(OUTER) JOIN:- This join returns all records from the right table, and the matched records from the left table. FULL(OUTER) JOIN:- This join returns all records when there is s match in either left or the right table.

Sql CREATE Database

SQL CREATE DATABASE:- The SQL CREATE DATABASE Statement is used by a developer to create a Database. SYNTAX:- CREATE DATABASE databasename; Example:- The following SQL statement creates a database called "test" :- CREATE DATABASE test; SQL DROP DATABASE:- The SQL DROP DATABASE  Statement is used to DROP an existing SQL database . Dropping a Database will result in the loss of complete information stored in the database. SYNTAX:- DROP DATABASE databasename; Example:-  The following statement will delete the database named  "test" :- DROP DATABASE test ; SQL RENAME DATABASE:- SQL RENAME DATABASE Statement is used to change the name of your old database to a new database. SYNTAX:- RENAME DATABASE old_db_name to new_db_name; SQL SELECT DATABASE:- In MySql, you need to first select the database before executing any query on the table. SYNTAX: - USE DATABASE database_name ;

Sql Backup Database

Backup Database:- The BACKUP DATABASE statement is used to create a full backup of an existing SQL Database. SYNTAX:- BACKUP DATABASE databasename TO DISK = 'filepath'; The SQL BACKUP WITH DIFFERENTIAL STATEMENT:- A differential back up only backs up the part of the database that have changed since the last full database backup. SYNTAX:- BACKUP DATABASE databasename TO DISK ='filepath' WITH DIFFERENTIAL; EXAMPLE:- The following SQL statement creates a full back up of the existing database "test" to the D disk:- BACKUP DATABASE test TO DISK = 'D:\backups\test.bak'; Backup With Differential Example:- BACKUP DATABASE test TO DISK =    'D:\backups\test.bak'; WITH DIFFERETIAL; A differential backup reduces the backup time (since only the changes are backed up).

Sql Aliases

Image
SQL Aliases:-  SQL Aliases are used to give a table, or a column in a table, a temporary name. The use of table aliases is to rename a table in a specific SQL statement. The renaming is a temporary change and the actual table name does not change in the database. Aliases are often used to make column names more readable. An alias only exists for the duration of the query. Alias Column Syntax:- SELECT column_name AS alias_name FROM table_name WHERE condition; Alias Table Syntax:- SELECT column1 , column2 , ... FROM table_name AS alias_name WHERE condition; Alias Column Example:- Consider the table STUDENT having the following records:- SELECT StudentID AS ID, Hometown AS Address FROM STUDENT WHERE Age>22 ;  OUTPUT:- Alias Table Example:- Consider two tables having the following records:- STUDENT TABLE:- DEPARTMENTS TABLE:- In the below query we use Alias for table STUDENT is "O" and for the table DEPARTMENTS is "D" . Now we want to Select STUDENTID, ...