- SQL keywords are not case-sensitive which means SELECT is the same as select.
- Database and Table names may be case-sensitive, that depends on the operating system. This means database and table names are case-sensitive on Linux/Unix operating systems and case-insensitive on Windows operating systems.
Comments in SQL
Comments are ignored by database engine. We write comments to provide information and better understanding of the SQL statement.
There are two ways to write comments in SQL statements
- Begin the comment with — (two hyphens): It is best for single line comment
- Begin the comment with a slash and an asterisk (/*) and end the comment with an asterisk and a slash (*/): It is best for multi-line comments.
For single-line comment
-- This is for single line comment SELECT column_name FROM tble_name WHERE condition;
For multi-line comment
/* This is for multi-line comments*/ SELECT column_name FROM tble_name WHERE condition;
SQL Syntax
Syntax for SQL SELECT Statement
SELECT column1, column2, ..... FROM table_name
Syntax for SQL UPDATE
UPDATE table_name SET column1 = value1, column2 = value2, column3 = value3, ...columnN = valueN WHERE [CONDITIONs];
Syntax for SQL DELETE
DELETE FROM table_name WHERE [CONDITIONs];
Syntax for SQL CREATE DATABASE
CREATE DATABASE database_name
Syntax for SQL ALTER DATABASE
Syntax for SQL DROP DATABASE
DROP DATABASE database_name
Syntax for SQL CREATE TABLE
CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype, ..... ..... columnN datatype, PRIMARY KEY( one or more column) );
Syntax for SQL ALTER TABLE
ALTER TABLE table_name [DROP|MODIFY|ADD] column_name [datatype];
Syntax for SQL DROP TABLE
DROP TABLE table_name;
Syntax for SQL CREATE INDEX
Syntax for SQL DROP INDEX
Syntax for SQL INSERT INTO