0% found this document useful (0 votes)
4 views

Mysql Basic Notes-1

The document provides a series of SQL commands for managing a MySQL database, including creating, opening, and dropping databases. It details how to create and modify tables, insert and delete records, and view database structures and contents. Additionally, it includes commands for altering table structures and managing data within tables.

Uploaded by

joyalprincess
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Mysql Basic Notes-1

The document provides a series of SQL commands for managing a MySQL database, including creating, opening, and dropping databases. It details how to create and modify tables, insert and delete records, and view database structures and contents. Additionally, it includes commands for altering table structures and managing data within tables.

Uploaded by

joyalprincess
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Create Database?

1. CREATE DATABASE sec_aids;

Open Database?
2. Use sec_aids;

Drop Database?
3. Drop database sec_aids;

To view all Databases in Mysql?


4. Show databases;

How to open Db?


5. ?

To create a new table?


6. CREATE TABLE users(id INT NOT NULL AUTO_INCREMENT, name VARCHAR(50) NOT
NULL, age INT NOT NULL,PRIMARY KEY(id));

To view all tables in a database?


7. Show tables;

To view structure of a table?


8. DESCRIBE users;

To insert a new column inside a table?

9. ALTER TABLE users ADD gender VARCHAR(10) NOT NULL AFTER AGE;
10. describe users;
To insert a multiple columns inside a table?
11. ALTER TABLE users ADD city VARCHAR(50) NOT NULL, ADD contact VARCHAR(50)
NOT NULL;
12. describe users;

To modify a column in a table?


13. ALTER TABLE users MODIFY contact VARCHAR(25) NOT NULL;
14. describe users;

To rename a table?
15. ALTER TABLE users RENAME TO students;
16. Show tables;

To view records in a Table?


17. SELECT * FROM students;
To insert a record into a table without mention column names?
18. INSERT INTO students VALUES(NULL,'Ram',25,'Male','Salem','9874563210');
19. Select *from students;

To insert multiple records into a table with mention column names?


20. INSERT INTO students(name,age,gender,city,contact) VALUES
('Ravi',23,'Male','Namakkal','9876543210'),('Sara',23,'Female','Erode','9874521360');
21. select *from students;

To delete a record from a table?


22. DELETE FROM students WHERE id=3;
23. Select *from students;

To modify/update a record in a Table?


24. UPDATE students SET city='Hosur',contact='9988776655' WHERE id=2;
25. select *from students;

To clear all data (or) records from a table?


26. TRUNCATE TABLE students;

You might also like