Simple SQL scripts for beginners that allows to manage database easily
SQL i.e. Structured Query language is used to access the database. It is also used to build various websites. There are various commands used in sql are: Create, Insert, Delete, Update, Select, Join, Distinct, etc.
SQL scripts/codes for:
- Creating table in SQL.
- Inserting data into table.
- Selecting data from table.
- Updating data into table.
- Deleting table.
1. Code for creating a table in SQL:
/* Table Name: T_Person */
CREATE TABLE T_Person
(
P_ID int,
LastName varchar(50),
FirstName varchar(50),
Address varchar(50),
City varchar(50)
)
P_ID LastName FirstName Address City
2. Code for inserting data into table:
/* Table Name: T_Person */
INSERT INTO T_Person
VALUES(1, 'utreja', 'jeenu', 'Anand Nagar', 'Rajpura')
P_ID LastName FirstName Address City
1 utreja jeenu Anand Nagar Rajpura
3. Code for selecting data from table:
/* Table Name: T_Person */
SELECT * FROM T_Person
P_ID LastName FirstName Address City
1 utreja jeenu Anand Nagar Rajpura
2 kapoor pihu Bakken 22 Stavanger
3 sharma pooja Storgt 20 Sandnes
4. Code for updating data into table:
/* Table Name: T_Person */
UPDATE T_Person
SET Address='Timoteivn 10', City='Sandnes'
WHERE LastName='gupta' AND FirstName='khushi'
1 utreja jeenu Anand Nagar Rajpura
2 kapoor pihu Bakken 22 Stavanger
3 sharma pooja Storgt 20 Sandnes
4 gupta khushi Timoteivn 10 Sandnes
5. Code for deleting data from table:
/* Table Name: T_Person */
DELETE * FROM T_Person