[go: up one dir, main page]

0% found this document useful (0 votes)
56 views8 pages

SQL Assignment

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 8

Assignment

SQL-

Structured Query Language or SQL is a standard Database language which is used to create,
maintain and retrieve the data from relational databases like MySQL, Oracle, SQL Server,
PostGre, etc. The recent ISO standard version of SQL is SQL:2019.

SQL is one of the most widely used query language over the databases.
 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 & 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.

SQL stands for Structured Query Language. SQL is used to communicate with a database. It
is the standard language for relational database management systems. Some common
relational database management systems that use SQL are: Oracle, Sybase, Microsoft SQL
Server etc. The standard SQL commands such as "Select", "Insert", "Update", "Delete",
"Create", and "Drop" can be used to accomplish almost everything that one needs to do
with a database

SQL offers two main advantages. Firstly, it introduced the concept of accessing many
records with one single command. Secondly, it eliminates the need to specify how to reach a
record, e.g. with or without an index.

Uses-

 SQL can execute queries against a database


 SQL can retrieve data from a database
 SQL can insert records in a database
 SQL can update records in a database
 SQL can delete records from a database
Assignment

SQL Commands-

 SELECT - extracts data from a database


 UPDATE - updates data in a database
 DELETE - deletes data from a database
 INSERT INTO - inserts new data into a database
 CREATE DATABASE - creates a new database
 ALTER DATABASE - modifies a database
 CREATE TABLE - creates a new table
 ALTER TABLE - modifies a table
 DROP TABLE - deletes a table
 CREATE INDEX - creates an index (search key)
 DROP INDEX - deletes an index
Assignment

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

CREATE TABLE Cars (Brand char(10), Conditioning char(10), Fuel char(10), KMsDriven int(10),
Model char(10), RegirtereCity char(10), Transaction char(10));

To verify that the table was created the way we expected, we use a DESCRIBE statement. It
can be used any time, for example, if you forget the names of the columns in your table or
what types they have.
Assignment

The INSERT INTO statement is used to insert new records in a table. It is possible to write
the INSERT INTO statement in two ways.

The SQL DELETE Query is used to delete the existing records from a table. You can use the
WHERE clause with a DELETE query to delete the selected rows, otherwise all the records
would be deleted.
Assignment

The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.
The ALTER TABLE statement is also used to add and drop various constraints on an existing
table.
Assignment

The SUBSTRING () function extracts some characters from a string.

SUBSTRING (string, start, length)

The AS command is used to rename a column or table with an alias.

An alias only exists for the duration of the query.


Assignment

The SQL CROSS JOIN produces a result set which is the number of rows in the first table
multiplied by the number of rows in the second table if no WHERE clause is used along with
CROSS JOIN. This kind of result is called as Cartesian Product.

If WHERE clause is used with CROSS JOIN, it functions like an INNER JOIN.

The Subquery can be nested inside a SELECT, INSERT, UPDATE, or DELETE statement or
inside another subquery.

A subquery is usually added within the WHERE Clause of another SQL SELECT statement.
Assignment

The SQL RIGHT JOIN, joins two tables and fetches rows based on a condition, which is
matching in both the tables ( before and after the JOIN clause mentioned in the syntax
below) , and the unmatched rows will also be available from the table written after the JOIN
clause ( mentioned in the syntax below ).

The SQL LEFT JOIN (specified with the keywords LEFT JOIN and ON) joins two tables and
fetches all matching rows of two tables for which the SQL-expression is true, plus rows from
the first table that do not match any row in the second table.

You might also like