SQL Commands

SQL (Structured Query Language) is a programming language used for managing and manipulating relational databases. Here are some common SQL commands:

CREATE TABLE: Creates a new table in the database.

CREATE TABLE table_name (
    column1 datatype,
    column2 datatype,

Viewing Table: To view and display the name of the tables in used database, you can use SHOW TABLES


View Table Structure: To view and display the structure of the table we can use DESCRIBE command.

Syntax: DESCRIBE<tablename>

SELECT Command: Retrieves data from one or more tables.

SELECT column1, column2 FROM table_name WHERE condition;

INSERT INTO: Adds new rows of data into a table.

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

UPDATE: Modifies existing data in a table.

UPDATE table_name SET column1 = value1 WHERE condition;

DELETE: Removes rows of data from a table.

DELETE FROM table_name WHERE condition;

Rename Column : Using alter command we can change the column name of the table.


Remove Column : How to remove table column

Syntax: ALTER TABLE <tablename> DROP <columnname> 

ALTER TABLE: Modifies an existing table structure.

ALTER TABLE table_name ADD column_name datatype;

DROP TABLE: Deletes an entire table from the database.

Syntax: DROP TABLE table_name;

JOIN: Combines rows from two or more tables based on a related column.

Syntax: SELECT column1, column2 FROM table1 JOIN table2 ON table1.column_id = table2.column_id;

GROUP BY: Groups rows that have the same values into summary rows.

Syntax: SELECT column1, COUNT(*) FROM table_name GROUP BY column1;

ORDER BY: Sorts the result set in ascending or descending order.

Syntax: SELECT column1, column2 FROM table_name ORDER BY column1 ASC;

Creating Database: Create Database command is used to create a database in database server.

Syntax: CREATE DATABASE <dbname>

Show Databases: Show database command is used to display all the databases which is already been created and stored in database Server.

Syntax: Show Databases;

Open Database: For open or use any perticular database you can use USE command.

Syntax: USE <dbname>

Removing Database: If you want to remove some or any database for that we can use DROP DATABASE command.

Syntax: DROP DATABASE <dbname>

Keep Learning 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *