<-- Chapter 1 Introduction to SQL
Chapter 2
SQL Syntax
SQL Syntax : SQL syntax is basically followed by sql commands which modifies the database tables such as "users" , "students" etc. All the SQL statements always starts with the keywords SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW . All these statements ends with semicolon i.e ";" . In SQL statements table name plays a big role , whether table exists in the database or not.
Important point is to be noted that SQL is case insensitive, it means select and SELECT known as the same meaning and functioning. They both work as same.
SQL contains many commands to modify database tables.
SELECT column1, column2....columnN
FROM tablename;
SELECT DISTINCT column_name
FROM tablename;
SELECT column1, column2....columnN
FROM tablename
WHERE CONDITION;
SELECT column1, column2....columnN
FROM tablename
WHERE CONDITION-1 {AND|OR} CONDITION-2;
SELECT column1, column2....columnN
FROM tablename
WHERE columnname IN (value-1, value-2,...value-N);
SELECT column1, column2....columnN
FROM tablename
WHERE columnname BETWEEN value-1 AND value-2;
SELECT column1, column2....columnN
FROM tablename
WHERE columnname LIKE { PATTERN };
SELECT column1, column2....columnN
FROM tablename
WHERE CONDITION
ORDER BY columnname {ASC|DESC};
SELECT SUM(columnname)
FROM tablename
WHERE CONDITION
GROUP BY columnname;
SELECT COUNT(columnname)
FROM tablename
WHERE CONDITION;
SELECT SUM(columnname)
FROM tablename
WHERE CONDITION
GROUP BY columnname
HAVING (arithmatic function condition);
CREATE TABLE tablename(
column1 datatype,
column2 datatype,
column3 datatype,
.....
columnN datatype,
PRIMARY KEY( one or more columns )
);
DROP TABLE table_name;
CREATE UNIQUE INDEX index_name
ON table_name ( column1, column2,...columnN);
ALTER TABLE table_name
DROP INDEX index_name;
DESC table_name;
TRUNCATE TABLE table_name;
ALTER TABLE table_name {ADD|DROP|MODIFY} column_name {data_ype};
-
ALTER TABLE Statement (Rename)
ALTER TABLE table_name RENAME TO new_table_name;
INSERT INTO table_name( column1, column2....columnN)
VALUES ( value1, value2....valueN);
UPDATE table_name
SET column1 = value1, column2 = value2....columnN=valueN
[ WHERE CONDITION ];
DELETE FROM table_name
WHERE {CONDITION};
-
CREATE DATABASE Statement
CREATE DATABASE database_name;
DROP DATABASE database_name;
USE database_name;
COMMIT;
ROLLBACK;
Chapter 3: SQL Select -->
0 Comment(s)