Posts

Showing posts from December, 2018

What is basic SELECT statement?

Image
SELECT Statement
A SELECT statement retrieves data from the database. With SELECT statement PROJECTION, SELECTION and JOIN can be performed on database tables.
As data in relational database is stored in TABLES. TABLE has ROW and COLUMN structure. With SELECT statement all rows and all columns can be retrieved, this is known as PROJECTION. But, if rows and columns are retrieved on the basis of some condition, it is known as SELECTION. And suppose if some information is needed and that is stored in two or more different tables but are related, use JOINS to retrieve it from two or more tables.
In SQL, basic SELECT statements are as follows:
SELECT * FROM [table_name];
SELECT[column1][column2][column3],..... FROM  [table_name];
SELECT and FROM are known as clauses. 
SELECT clause allows to specify columns to be selected from the database table. 
FROM clause allows to specify table name that has those column to be selected.
Semicolon at the end of SELECT statement specify the end of SQL statemen…

What is basic SELECT statement?

Image
SELECT Statement
A SELECT statement retrieves data from the database. With SELECT statement PROJECTION, SELECTION and JOIN can be performed on database tables.
As data in relational database is stored in TABLES. TABLE has ROW and COLUMN structure. With SELECT statement all rows and all columns can be retrieved, this is known as PROJECTION. But, if rows and columns are retrieved on the basis of some condition, it is known as SELECTION. And suppose if some information is needed and that is stored in two or more different tables but are related, use JOINS to retrieve it from two or more tables.
In SQL, basic SELECT statements are as follows:
SELECT * FROM [table_name];
SELECT[column1][column2][column3],..... FROM  [table_name];
SELECT and FROM are known as clauses. 
SELECT clause allows to specify columns to be selected from the database table. 
FROM clause allows to specify table name that has those column to be selected.
Semicolon at the end of SELECT statement specify the end of SQL statemen…

What are different SQL statements?

SQL Statements

Basically there are three types of SQL statements:

1. DDL  - Data Definition Language
2. DML - Data Manipulation Language
3. DCL  - Data Control Language 


1) Data Definition Language:It is used to define the database structure. It includes following statements:

CREATE

Very basic is the create table statement, used to create a database table:

CREATE TABLE [table_name] (
[column1] datatype,
[column2] datatype,
.....
);

ALTER

ALTER statement is used to add, delete or modify database table columns.

ALTER TABLE [table_name]
ADD [column_name] datatype;

ALTER TABLE [table_name]
DROP COLUMN [column_name];

ALTER TABLE [table_name]
MODIFY COLUMN [column_name] datatype;


DROP

DROP statement is used to remove complete table definition with all data.

DROP TABLE[table_name];


2) Data Manipulation Language:It is used to manipulate data in database. It includes following statements:
SELECT

Very basic SELECT statement is for selecting rows and columns from the database table.

SELECT [*/column_name1, column_name2, .…

What is SQL?

SQL

SQL stands for Structured Query Language.

SQL allows to access and manipulate data stored in relational database.

In IT industry, it is also known as See-Quell.

There are many implementation of SQL are available. Following are some of the DBs that provides SQL:


MySQL , SQL Server, MS Access, Oracle, Postgres etc.







Differentiate between DDL and DML

DDL DDL stands for Data Definition Language. DDL comprises of statements that are used to define the database structure or database schema.

Following are DDL statements:

CREATE - Statement used for creating database objects like TABLE, VIEW etc.

ALTER - Statement used for modifying database structure.

DROP - Statement used for deleting database objects.

TRUNCATE - Statement for removing all records from a table and free the allocated space.

RENAME - Statement for renaming database object.



DML

DML stands for Data Manipulation Language. DML comprises of statements for managing data within the database.

Following are DML statements:

SELECT - Statement used to retrieve data from the TABLE.

INSERT - Statement used to insert/push data in the TABLE.

UPDATE - Statement used to update the existing data in the TABLE.

DELETE - Statement used to delete data from the TABLE.