SQL is a language to operate databases; it includes database creation, deletion, fetching rows, modifying rows, etc. SQL is an ANSI (American National Standards Institute) standard language, but there are many different versions of the SQL language.
What is SQL?
SQL is Structured Query Language, which is a computer language for storing, manipulating and retrieving data stored in a relational database.
SQL is the standard language for Relational Database System. All the Relational Database Management Systems (RDMS) like MySQL, MS Access, Oracle, Sybase, Informix, Postgres and SQL Server use SQL as their standard database language.
Also, they are using different dialects, such as −
    -MS SQL Server using T-SQL,
    -Oracle using PL/SQL,
    -MS Access version of SQL is called JET SQL (native format) etc.
SQL's "INSERT INTO" statement can be used to add rows of data to a table in the database.
Why SQL
SQL is widely popular because it offers the following advantages −
    -Allows users to access data in the relational database management systems.
    -Allows users to describe the data.
    -Allows users to define the data in a database and manipulate that data.
    -Allows to embed within other languages using SQL modules, libraries and pre-compilers.
    -Allows users to create and drop databases and tables.
    -Allows users to create view, stored procedure, functions in a database.
    -Allows users to set permissions on tables, procedures and views.
Syntax
Below is the normal use case for "INSERT INTO" - where you insert values manually. It is followed by the table name and an optional list of columns that should be filled with the data. Then follows the "VALUES" keyword and the actual values you want to insert.
Sytnax:
Insert into table_Name (Column_a,Column_b,Column_C,…..)Values(“Value_a”,”Value_b”,”Value_C”,….)
Insert Distinct Records INTO New Tables
In order to copy data from an existing table to a new one, you can use the "INSERT INTO SELECT DISTINCT" pattern. After "INSERT INTO", you specify the target table's name – tblStudent in the below case.
Then you select the columns that should be copied over from the source table – StudentInformation in this case. You use the "DISTINCT" keyword to only copy over distinct TblStudent.
Example
Insert into TblStudent Select Distinct StudentName,Gender from StudentInformation
Migrating Data Into a New Table
Let us migrate the data into new tables. You will use the following pattern:
Syntax
Insert into…
Select Distinct...
From…
It can be broken up into two parts:
Example
Select Distinct Column_name1,Column_Name2,…
From Table_Name;
Insert into studentinformation
Select Distinct StudentName,Gender
From tblStudent
Please Watching My Video is Below
No comments:
Post a Comment