SQL Syntax
SQL is not syntax strict like JavaScript which mean to say that in SQL uppercases and lowercases don’t matter as long as you have spelled them correctly.
For example:
“SELECT * FROM users”
AND “SELECT * FROM users”
is the same
SQL queries can be ended with a semicolon or can be simply ignored, however there are some DBMS which require that the query must be ended with a semicolon, else they won’t execute the query.
SQL Queries can be nested in other SQL queries for performing complex operations in a single go.
SQL queries can be written in single line as well as can be broken to multiline for better readability.
For example:
“SELECT * FROM users WHERE lastname=’Smith’”
This query can be written as multiline
- “SELECT *
- FROM Users
- WHERE lastname=’smith’”
This increases the readability.
Syntax for SQL queries must be followed correctly and cannot written out of order i.e. “select * from users” cannot be written as “select from * users”
Simple/most commonly used SQL commands
Select – this SQL statements allow us to retrieve data from the database, based upon our conditions we specify.
Insert – this SQL statement allows us to insert data to some specific table in the database.
Update – this SQL statement is used to modify or update the existing record based on the condition we specify.
Delete – this SQL statement will delete a data record from the table we mention.
Extended SQL Operations
Create Database – to create a completely new database with SQL without having to create the database from the dbms itself.
Alter Database – to modify the database structure, like adding a new table or removing tables.
Create Table – this command is used to create a new table in the database selected.
Alter table – modifies the table structure.
Drop table – simply deletes all the data records and the table itself from the database.
Create index – this command is used to create a search index on some specific column of the table.
Drop index – removes the search key from the column of the table.
Add new comment
- 537 views