SQL
UPDATE Statement

UPDATE statement is used to edit the records of a table.

with WHERE

Syntax

 

    UPDATE table_name
    SET column1 = value1, column2 = value2, ...
    WHERE condition;

Example

  UPDATE Customers
	SET CustomerName = 'john', City= 'Austria'
	WHERE CustomerID = 6;

without WHERE

Whenever we use UPDATE Statement without WHERE clause it will Update all the records in the table.

Syntax


    UPDATE table_name
    SET column1 = value1, column2 = value2...;

Example

 

  UPDATE Customers
  SET CustomerName='john';

  

SQL
INSERT INTO Statement

INSERT INTO statement is used to insert the records in table. We can insert records in table in two ways, the most commonly used way for insert is to specify both the column names and values.

All Columns

In this method there is no need to specify the column names in SQL query, however make sure the order of the values and columns.

Syntax

  INSERT INTO table_name
  VALUES (value1, value2, value3, ...);

 

Example

  INSERT INTO Customers
  VALUES ('john', 'Michel john ', 'St 55', 'louse angelus', '4900', 'USA');

Selective Columns

Syntax

  INSERT INTO table_name (column1, column2, column3, ...)
  VALUES (value1, value2, value3, ...); 

 

Example

    INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)
    VALUES ('john', 'Michel john ', 'St 55', 'louse angelus', '4900', 'USA');

Introduction to
SQL

SQL is a standard language for sorting, manipulating and retrieving data from databases. SQL stands for Structured Query Language that let you access and manipulate databases.

Power of SQL:

  • SQL can execute queries against a database
  • SQL is used to insert data into a database
  • SQL is used to retrieve data from a database
  • SQL is used to update/edit data of a database
  • SQL is used to delete/remove data of a database
  • SQL is used to create database and tables
  • SQL is used to create stored procedures
  • SQL is used to create view in a database
  • SQL is used to set permission on tables, procedures and views

Commands of SQL

Below are some most important and basic commands of SQL.

CommandDescription
SELECTIt extracts data from a database
UPDATEIt updates data in a database
DELETEIt deletes data from a database
INSERT INTOIt inserts new data into a database
CREATE DATABASEIt creates a new database
ALTER DATABASEIt modifies a database
CREATE TABLEIt creates a new table
ALTER TABLEIt modifies a table
DROP TABLEIt deletes a table
CREATE INDEXIt creates an index
DROP INDEXIt deletes an index