Command Done in Data Base
1)SELECT column_name,column_name
FROM table_name;
AND
SELECT * FROM table_name;
2)
1)SELECT column_name,column_name
FROM table_name;
AND
SELECT * FROM table_name;
2)
SQL SELECT DISTINCT Syntax
SELECT DISTINCT column_name,column_name
FROM table_name;
3)
SQL WHERE Syntax
SELECT column_name,column_name
FROM table_name
WHERE column_name operator value;
4)
AND Operator Example
SELECT * FROM Customers
WHERE Country='Germany'
AND City='Berlin';
OR Operator
SELECT * FROM Customers
WHERE City='Berlin'
OR City='München';
5)
SQL INSERT INTO Syntax
INSERT INTO table_name
VALUES (value1,value2,value3,...);
6)
SQL UPDATE Syntax
UPDATE table_name
SET column1=value1,column2=value2,...
WHERE some_column=some_value;
7)
SQL DELETE Syntax
DELETE FROM table_name
WHERE some_column=some_value;
8) TRUNCATE Table Name;
9)
SQL Alias Syntax for Columns
SELECT column_name AS alias_name
FROM table_name;
10)
SQL Alias Syntax for Tables
SELECT column_name(s)
FROM table_name AS alias_name;
11)
SQL FULL OUTER JOIN Syntax
SELECT column_name(s)
FROM table1
FULL OUTER JOIN table2
ON table1.column_name=table2.column_name;
12)
SQL PRIMARY KEY Constraint on CREATE TABLE
CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
PRIMARY KEY (P_Id)
)
13) SQL FOREIGN KEY Constraint on CREATE TABLE
CREATE TABLE Orders
(
O_Id int NOT NULL,
OrderNo int NOT NULL,
P_Id int,
PRIMARY KEY (O_Id),
FOREIGN KEY (P_Id) REFERENCES Persons(P_Id)
)
14)The DROP TABLE Statement
DROP TABLE table_name;
15)
SQL ALTER TABLE Syntax
To add a column in a table, use the following syntax:
ALTER TABLE table_name
ADD column_name datatype;
16)
SQL CREATE VIEW Syntax
CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
Example
CREATE VIEW [Current Product List] AS
SELECT ProductID,ProductName
FROM Products
WHERE Discontinued=No;
We can query the view above as follows:
SELECT * FROM [Current Product List];
These are the 16 queries which Ma'am Taught.
Thanks And Regards