20+ SQL Commands with Syntax & Programming Examples

Here’s a reference list of normally utilized SQL commands:

SQL Statement Syntax Description
ALTER TABLE ALTER TABLE table_name
ADD column_name datatypeorALTER TABLE table_name
DROP COLUMN column_name
You can add a column to a table in the database.
AND / OR SELECT column_name(s)
FROM table_name
WHERE condition
AND|OR condition
These operators combine two conditions and used to filter records.
AS (alias) SELECT column_name AS column_alias
FROM table_nameorSELECT column_name
FROM table_name  AS table_alias
SQL aliases are used to give a temporary name to a table or a column in the table.
BETWEEN SELECT column_name(s)
FROM table_name
WHERE column_name
BETWEEN value1 AND value2
Used for select values within a certain range.
CREATE DATABASE CREATE DATABASE database_name Used to create a new SQL database
CREATE TABLE CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,

)
Used to create a new table in the database. You can specify the name of the table and the name of each column.
CREATE INDEX CREATE INDEX index_name
ON table_name (column_name)orCREATE UNIQUE INDEX index_name
ON table_name (column_name) 
This statement used to create indexes in tables. AN index used to retrieve data very fast from Db.
CREATE VIEW CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition;
The view is a virtual table, which contains columns and rows just like a real table.
DELETE DELETE FROM table_name
WHERE some_column=some_valueorDELETE FROM table_name
Note: Deletes the entire table.DELETE * FROM table_name
Note: Deletes the entire table.
Used to delete existing records form a table.
DROP DATABASE DROP DATABASE database_name; Used to drop an existing SQL database.
DROP INDEX DROP INDEX table_name.index_name (SQL Server)
DROP INDEX index_name ON table_name (MS Access)
DROP INDEX index_name (DB2/Oracle)
ALTER TABLE table_name
DROP INDEX index_name (MySQL)
Used to delete an index from a table.
DROP TABLE DROP TABLE table_name Used to drop an existing table in a database.
EXISTS IF EXISTS (SELECT * FROM table_name WHERE id = ?)
BEGIN
–do what needs to be done if exists
END
ELSE
BEGIN
–do what needs to be done if not
END
This operator used to test for the existence of any record in a subquery.
GROUP BY SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
Used with aggregate functions (COUNT, MAX, MIN, SUM, AVG) to group the result-set by one or more columns.
HAVING SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value
This clause was added to SQL because the WHERE keyword could not be used with aggregate functions.
IN SELECT column_name(s)
FROM table_name
WHERE column_name
IN (value1,value2,..)
This operator allows specifying multiple values in WHERE clause. It is also a shorthand for multiple OR condition.
INSERT INTO INSERT INTO table_name
VALUES (value1, value2, value3,….)orINSERT INTO table_name
(column1, column2, column3,…)
VALUES (value1, value2, value3,….) 
Used to insert new records in a table.
INNER JOIN SELECT column_name(s)
FROM table_name1
INNER JOIN table_name2
ON table_name1.column_name=table_name2.column_name
Used to selects records that have matching values in both tables.
LEFT JOIN SELECT column_name(s)
FROM table_name1
LEFT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
Use to returns all records from the left table
RIGHT JOIN SELECT column_name(s)
FROM table_name1
RIGHT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
Use to returns all records from the right table.
FULL JOIN SELECT column_name(s)
FROM table_name1
FULL JOIN table_name2
ON table_name1.column_name=table_name2.column_name
Used to return all records when there is a match in either left or right table records.
LIKE SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern
Used to search for a specified pattern in a column in a WHERE clause.
ORDER BY SELECT column_name(s)
FROM table_name
ORDER BY column_name [ASC|DESC]
Used to sort the result in ascending or descending order.
SELECT SELECT column_name(s)
FROM table_name
Used to select data from a database.
SELECT * SELECT *
FROM table_name
To select all the fields available in the table.
SELECT DISTINCT SELECT DISTINCT column_name(s)
FROM table_name
To return only different values.
SELECT INTO SELECT *
INTO new_table_name [IN externaldatabase]
FROM old_table_nameorSELECT column_name(s)
INTO new_table_name [IN externaldatabase]
FROM old_table_name 
Used to copies data from one table into a new table.
SELECT TOP SELECT TOP number|percent column_name(s)
FROM table_name
To specify the number of records to return.
TRUNCATE TABLE TRUNCATE TABLE table_name Used to empty a table completely. It’s required the DROP privilege.
UNION SELECT column_name(s) FROM table_name1
UNION
SELECT column_name(s) FROM table_name2
Used to combine the result-set of two or more SELECT statements.
UNION ALL SELECT column_name(s) FROM table_name1
UNION ALL
SELECT column_name(s) FROM table_name2
To allow duplicate values, to combine the result-set of two or more SELECT statements.
UPDATE UPDATE table_name
SET column1=value, column2=value,…
WHERE some_column=some_value
Used to modify the existing records in a table.
WHERE SELECT column_name(s)
FROM table_name
WHERE column_name operator value
This clause is used to filter records also extract only those records that fulfil a specified condition.

 

6 Basic MySQL Data Types with [Ranges & Descriptions]

SQL stands for the structured query language. MySQL Data Types is a database management system that allows you to manage relational databases. It is open source software backed by Oracle. It means you can use MySQL without paying a dime. Also, if you want, you can change its source code to suit your needs. SQL is the standardized language used to access the database. SQL contains three parts:
Data definition language includes statements that help you define the database and its objects e.g. views, triggers, etc.
Data manipulation language contains statements that allow you to update and query data.
Data control language allows you to grant permission to a user to access specific data in the database.

MySQL Data Types:

freepik mysql data types  
MySQL underpins various SQL data types broken into three categories:
  1. Numeric
  2. Date and Time Types
  3. String Types
  4. Spatial Datatypes
  5. Boolean Datatypes
  6. The JSON Data Type
Let us now discuss them thoroughly:

1- Numeric Data Types

MySQL utilizes all the standard ANSI SQL numeric data types, so in case you’re returning to MySQL from an alternate database system, these definitions can look acquainted to you. The following list shows the common numeric data types and their descriptions:
Data Types
Ranges
Description
INT
Signed:-2147483648 to 2147483647Unsigned:0 to 4294967295
An ordinary estimated integer that can be signed or unsigned having a different range. You can determine a width of up to 11 digits.
TINYINT
Signed:– 128 to 127Unsigned:0 to 255
A very small integer that can be signed or unsigned. You can indicate a width of up to 4 digits.
SMALLINT
Signed:– 32768 to 32767Unsigned:0 to 65535
A small integer that can be signed or unsigned. You can determine a width of upto 5 digits.
MEDIUMINT
Signed:- 8388608 to 8388607Unsigned:0 to 16777215
A medium-sized integer that can be signed or unsigned. You can specify a width of up to 9 digits.
BIGINT
Signed:-9223372036854775808 to 9223372036854775807Unsigned:0 to 18446744073709551615
A substantial integer that can be signed or unsigned. You can specify a width of up to 20 digits.
FLOAT(M, D)
-1.79E+ 308 to 1.79E + 308
A floating point number that can’t be unsigned. You can characterize the presentation length (M) and the number of decimals (D). This isn’t required and will default to 10,2, where 2 is the number of decimals and 10 is the total number of digits (including decimals). Decimal accuracy can go to 24 places for a FLOAT.
DECIMAL(M, D)
-10^38+1 to 10^38 -1
An unloaded floating point number that can’t be unsigned. In the unloaded decimals, every decimal relates to one byte. Characterizing the display length (M) and the number of decimals (D) is required. NUMERIC is an equivalent word for DECIMAL.

2- Date and Time Types

The MySQL date and time data types are as follows:
Data  Type
Description
DATE
Stores date in this format YYYY-MM-DD
TIME
Stores the time in an HH:MM: SS organize.
DATETIME
A date and time blend in YYYY-MM-DD HH:MM: SS format
TIMESTAMP
Stores number of seconds go since the Unix age (‘1970-01-01 00:00:00’ UTC)
YEAR(M)
Stores a year in a 2-digit or a 4-digit design.

3- String Data Types

In spite of the fact that the numeric and date types are fun, most data you’ll store will be in a string format. This list depicts the basic string data types in MySQL.
Data Type
Description
CHAR(M)
A fixed length string somewhere in the range of 1 and 255 characters long.
VARCHAR(M)
A variable-length string somewhere in the range of 1 and 255 characters in length.
BLOB or TEXT
A field with a most extreme length of 65535 characters.
TINYBLOB
or TINYTEXT
A BLOB or TEXT segment with a maximum length of 255 characters. You do not indicate a length with TINYBLOB or TINYTEXT.
MEDIUMBLOB
or MEDIUMTEXT
A BLOB or TEXT column with a maximum length of 16777215 characters. You do not indicate a length with MEDIUMBLOB or MEDIUMTEXT.
ENUM
An enumeration, which is a fancy term for the list. When defining an ENUM, you are making a list of items from which the value must be selected (or it can be NULL).

4- Spatial Data Types

MySQL bolsters many spatial data types that contain different sorts of geometrical and geological values are GEOMETRY, POINT, LINESTRING, POLYGON, GEOMETERYCOLLECTION, MULTILINESTRING, MULTIPOINT, MULTIPOLYGON.

5- BOOLEAN Data Type

The BOOLEAN data type supports the capacity of two values TRUE or FALSE. No parameters are required while declaring a BOOLEAN data type. Use the case-insensitive keywords TRUE or FALSE to assign a value to a BOOLEAN data type. Comparisons using the BOOLEAN data type should also use these keywords. If you attempt to assign any other value to a BOOLEAN data type, an error is raised.

MySQL Create Table:

To start with, the table creation command requires the Name of the Table, Name of the Fields & Definitions for each field

Syntax

Here is a conventional SQL language structure to make a MySQL table:
CREATE TABLE table_name (column_name column_type);

Creating Tables from CommandPrompt

It is easy to create a MySQL table from the mysql> prompt. You will use the SQL command CREATE TABLE to create a table.

Creating Tables Using PHP Script

To create a new table in an existing database you would need to use PHP function mysql_query(). You will pass its second argument with an appropriate SQL command to create a table.

C++ Compiler Download [Free Versions] With Complete Guide Method

1- C-Free [Free Version]

C++ Compiler Download [Free Version]: C-Free is the Best Code Compiling tool/ Available 32bit /64bit. Here you can Download the Free Version C++ Compiler of this Software

[Download Free Version]        

 

Registration Process

 Only copy the name, email and serial key and paste it in the register block of  C-Free and enjoy free version.
Name:   TEAM MESMERiZE
Email:   MESMERiZE@wejustdo.it
Serial:  5Onmluz+3IHs7MK+w9nGr83Dm7Ld+PCa5Iz4nvrh8InA9vDb

C-Free 5.0 Features

  • Click on the Above link and download the file.
  • After Downloading Install this & Click on ‘Help’ Button see in the below

cfree registeration

  • After clicking on Register Button then show you like this block / See Below.

  •  After the Registration process Now, you can use easily & Compile your code and see your results.

2- Borland C++ 5.02 [Free Version]

 

[Download Free Version]

 

 Complete Installation Method 

By: JHHJelpavo15

3- Dev C++

 

[Download Click Here]

 

download image

Complete Installation Method

ByTECH SEARCH

 

For more details: Click Here