Some Important SQL Command
Some Important SQL Command
1 Create Database
Syntax:
sql
Example:
sql
Syntax:
sql
Example:
sql
3. Create Table
Syntax:
sql
CREATE TABLE table_name (
...
);
Example:
Create a table ipstudents in the school database with the columns roll_no,
name, and marks
sql
name VARCHAR(100),
marks INT
);
Steps:
sql
USE school;
Then, create the table with the above CREATE TABLE command.
Here are the basic SQL commands for CRUD operations (Create, Read, Update,
Delete) in MySQL:
1. Create (Inserting data into a table)
Syntax:
sql
Copy code
Example:
sql
Or
INSERT INTO ipstudents VALUES (1, 'John Doe', 85), (2, ‘ram’, 95), (3, ‘suraj’,
55);
Syntax:
sql
WHERE condition;
Example:
Sql:
Sql:
Syntax:
sql
UPDATE table_name
WHERE condition;
Example:
Sql
UPDATE ipstudents
SET marks = 90
WHERE roll_no = 1;
Syntax:
sql
WHERE condition;
Example:
sql
WHERE roll_no = 1;
sql
These are the basic CRUD operations that help manage data in a MySQL
database
5. Add a New Column
The ALTER TABLE statement is used to add a new column to an existing table.
Syntax:
sql
Example:
sql
6. Delete a Column
To remove a column from a table, you use the ALTER TABLE command with the
DROP keyword.
Syntax:
sql
example
Syntax:
sql
Example:
sql