Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
58 views

Give Me All MySQL Commands Syntax in Detail

The document provides an overview of some common MySQL commands along with their syntax and examples. It describes commands for selecting, updating, deleting, inserting and managing data like CREATE DATABASE, ALTER DATABASE, CREATE TABLE, ALTER TABLE, DROP TABLE. Indexing commands like CREATE INDEX and DROP INDEX are also covered. The document aims to help with understanding essential MySQL commands and their usage.

Uploaded by

shaik shaheer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Give Me All MySQL Commands Syntax in Detail

The document provides an overview of some common MySQL commands along with their syntax and examples. It describes commands for selecting, updating, deleting, inserting and managing data like CREATE DATABASE, ALTER DATABASE, CREATE TABLE, ALTER TABLE, DROP TABLE. Indexing commands like CREATE INDEX and DROP INDEX are also covered. The document aims to help with understanding essential MySQL commands and their usage.

Uploaded by

shaik shaheer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Give me all MySQL commands

syntax in detail
There are many MySQL commands, but here are some of the most
important ones with their syntax:

SELECT - This command is used to extract data from a database.


The syntax is:

SELECT column_name, column_name

FROM table_name;

For example, the following command will extract the name and
age columns from the customers table:

SELECT name, age

FROM customers;

UPDATE - This command is used to update data in a database. The


syntax is:

UPDATE table_name

SET column_name = new_value

WHERE condition;

For example, the following command will update the age of all
customers whose name is "John" to 25:

UPDATE customers

SET age = 25
WHERE name = 'John';

DELETE - This command is used to delete data from a database. The


syntax is:

DELETE FROM table_name

WHERE condition;

For example, the following command will delete all customers whose
age is greater than 30:

DELETE FROM customers

WHERE age > 30;

INSERT INTO - This command is used to insert new data into a


database. The syntax is:

INSERT INTO table_name (column_name, column_name)

VALUES (value, value);

For example, the following command will insert a new customer into
the customers table with the name "Jane Doe" and the age 20:

INSERT INTO customers (name, age)

VALUES ('Jane Doe', 20);

CREATE DATABASE - This command is used to create a new


database. The syntax is:

CREATE DATABASE database_name;

ALTER DATABASE - This command is used to modify a database.


The syntax is:
ALTER DATABASE database_name

MODIFY CHARACTER SET charset_name

COLLATE collation_name;

CREATE TABLE - This command is used to create a new table. The


syntax is:

CREATE TABLE table_name (

column_name1 datatype,

column_name2 datatype,

...

table_constraints

);

For example, the following command will create a new table called
customers with two columns: name (a string) and age (an integer):

CREATE TABLE customers (

name VARCHAR(255),

age INT

);

ALTER TABLE - This command is used to modify a table. The syntax


is:

ALTER TABLE table_name


ADD column_name datatype;

For example, the following command will add a new column called
email (a string) to the customers table:

ALTER TABLE customers

ADD email VARCHAR(255);

DROP TABLE - This command is used to delete a table. The syntax


is:

DROP TABLE table_name;

For example, the following command will delete the customers table:

DROP TABLE customers;

CREATE INDEX - This command is used to create an index on a


table. An index is a data structure that helps MySQL find data more
quickly. The syntax is:

CREATE INDEX index_name ON table_name (column_name);

For example, the following command will create an index called


name_index on the name column of the customers table:

CREATE INDEX name_index ON customers (name);

DROP INDEX - This command is used to delete an index. The syntax


is:

DROP INDEX index_name ON table_name;

For example, the following command will delete the


name_index index from the customers table:
DROP INDEX name_index ON customers;

These are just some of the most important MySQL commands. For
more information, please refer to the MySQL documentation:
https://dev.mysql.com/doc/refman/8.0/en/

I hope this helps! Let me know if you have any other questions.

You might also like