Abc Assignment Help

SQL Queries

SQL Queries for Book Library Database Design.

Answer

SQL Queries

Almost all relational database management systems use SQL (Structured Query Language) for data manipulation and retrieval. SQL is the standard language for relational database systems. SQL is a non-procedural language.


DDL(Data Definition Language) Queries

                 DDL commands are used to define the data. For example, CREATE TABLE.


The CREATE TABLE Statement: 

The CREATE TABLE statement is used to create a table in a database.


Now we want to create a table called "Student" that contains three columns: StudentId,StudentFirstName,StudentLastName.                     


create table Student_tbl(StudentId  int primary key,
StudentFirstName  varchar(50) ,
StudentLastName  varchar(50) 
 );

                Table Created;


Drop Statement: 

Indexes, tables, and databases can easily be deleted/removed with the DROP statement.


DROP   TABLE Cources;

               

Alter  Statement: 

The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.


SQL ALTER TABLE Syntax:


ALTER   TABLE Student
ADD DateOfBirth date

                

DML(Data Manilpulation Language) Queries

                 DML commands such as, INSERT and DELETE are used to manipulate data.    


The SELECT Statement: 

The SELECT statement is used to select data from a database. If we select particular Column from the “Student” Table than SQL Queries is,


SELECT   StudentFirstName
FROM Student;


If we want to select all the columns from the "Student" table than SQL Queries is.


SELECT   * FROM Student;


 The INSERT INTO Statement: 

The INSERT INTO statement is used to insert a new row in a table.


SQL INSERT INTO Syntax: It is possible to write the INSERT INTO statement in two forms. The first form doesn't specify the column names where the data will be inserted, only their values:


INSERT   INTO table_name
VALUES (value1, value2, value3,...)


The second form specifies both the column names and the values to be inserted:


INSERT   INTO table_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...)


            Now we want to insert a new row in the "Student" table.



INSERT INTO Student_tbl ( StudentId,   StudentFirstname, StudentLastName )
VALUES (5, 'Lakshmi', 'Gupta');


                 Table Created;

The Delete Statement: 

The DELETE statement is used to delete rows in a table.

SQL DELETE Syntax:

DELETE   FROM table_name
WHERE some_column=some_value


Now we want to delete the person "Denny, Jain" in the "Student" table.

Delete All Rows: It is possible to delete all rows in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact:


DELETE   FROM table_name

or

DELETE * FROM table_name



Customer Testimonials