Insert query in MySQL

MySQL INSERT In MySQL, the INSERT statement is used to insert a single or multiple records into a table in a database. Syntax: INSERT into table_name(column_1, column_2, … column_n ) VALUES(value1, value2, .. valuen);   Example 1: MySQL INSERT single record insertion: Items table before insertion: ID NAME QUANTITY 1 Electronics 30 2 Sports 45 … Read more

QUERIES in MySQL

MySQL QUERIES In MySQL, we can execute many queries including the Select, Insert, Update, Delete, Drop, Alter table, and Create a table or database. MySQL Create Database Query: Uses: To create a MySQL database. Syntax: CREATE DATABASE database_name; Example: CREATE DATABASE stores; MySQL Select/Use Query: Uses: To retrieve records from the database. Syntax: USE database_name; … Read more

VIEW in MySQL

MySQL VIEWS The view is a virtual table in MySQL. It has no physical existence. It is created by joining one or more tables. Syntax: CREATE [OR REPLACE] VIEW name AS SELECT column_1, column_2, column_3,…… FROM table WHERE view_conditions; Parameters: name: It is used to specify the name of the MySQL VIEW to be created. … Read more

TRUNCATE TABLE in MySQL

TRUNCATE TABLE In MySQL, the TRUNCATE TABLE statement is used to truncate or remove table records but not the structure. Syntax: TRUNCATE TABLE table_name Example: TRUNCATE TABLE items; Output: Query OK, 0 rows affected <0.07 sec> Explanation: The “items” is an already existing table that is truncated thus deleting all the data. Verify the result … Read more

ALTER TABLE in MySQL

ALTER TABLE In MySQL, the ALTER TABLE statement is used to rename a table or a column in a table or to add, modify, drop, or delete a column in a table ALTER TABLE statement is used. Syntax: ALTER TABLE table_name action; ALTER TABLE ADD column: Syntax 1: To add a column in the existing … Read more

CREATE TABLE in MySQL

MySQL CREATE TABLE To create a new table in a database, MySQL provides the MySQL CREATE TABLE statement. Syntax 1: To create a Table in MySQL. CREATE TABLE table_name ( column_1 data_type column_constraint, column_2 data_type column_constraint, … ); Syntax 2: To see all the already created Tables in a database. SHOW tables; Syntax 3: To … Read more

Select Database in MySQL

SELECT DATABASE In MySQL, the USE command is used to select a particular MySQL database to work with. Syntax: USE name; Parameters: name: It is used to specify the name of the database to be selected. The database name, table name, and table fields’ names in MySQL are case-sensitive. Example: USE stores; Output: Database changed … Read more