A list of commonly used MySQL queries to create database, use database, create table, insert record, update record, delete record, select record, truncate table and drop table are given below.
MySQL create database is used to create database. For example
create database db1;
MySQL use database is used to select database. For example
use db1;
MySQL create query is used to create a table, view, procedure and function. For example:
CREATE TABLE customers (id int(10), name varchar(50), city varchar(50), PRIMARY KEY (id ) );
MySQL alter query is used to add, modify, delete or drop colums of a table. Let's see a query to add column in customers table:
ALTER TABLE customers ADD age varchar(50);
MySQL insert query is used to insert records into table. For example:
insert into customers values(101,'rahul','delhi');
MySQL update query is used to update records of a table. For example:
update customers set name='bob', city='london' where id=101;
MySQL update query is used to delete records of a table from database. For example:
delete from customers where id=101;
Oracle select query is used to fetch records from database. For example:
SELECT * from customers;
MySQL update query is used to truncate or remove records of a table. It doesn't remove structure. For example:
truncate table customers;
MySQL drop query is used to drop a table, view or database. It removes structure and data of a table if you drop table. For example:
drop table customers;