MariaDB (or MYSQL) Commands
Beyond Here
To Create a DB
To Create DB_Name
create database [DB_Name];
To See all the DB
To See all the DB in Server
show databases;
To Delete a DB
To Delete a DB_Name
drop database [DB_Name];
To Switch to a DB
To Switch to DB_Name
use [DB_Name];
To See Tables
To See all the Tables in the DB
show tables;
To Create a Table
To Create a Table with Field_Name_01 & Field_Name_02 & Field_Name_03 & Field_Name_04
CREATE TABLE `[Table_Name]` (
`Field_Name_01` int(11) NOT NULL,
`Field_Name_02` char(10) DEFAULT NULL,
`Field_Name_03` char(20) DEFAULT NULL,
`Field_Name_04` char(80) DEFAULT NULL,
`Field_Name_05` char(20) DEFAULT NULL,
PRIMARY KEY (`Field_Name_01`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
To Delete a Table
drop table [Table_Name];
To Show selected Records sorted
To Show Records sorted in an Field_Name_01 where Field_Name_02 is'XXXXXX' to'Y'
SELECT [Fild_Name_01], [Fild_Name_02] FROM [Table_Name] where [Field_Name_02] = 'XXXXXX' ORDER BY [Fild_Name_01];
To Show all Record in Table_Name_01 & Fild_Name_03 in Table_Name_02 with Table_Name_01.Fild_Name_01=Table_Name_02.Fild_Name_02'
SELECT [Table_Name_01].*, [Table_Name_02].[Fild_Name_03]
FROM [Table_Name_01] JOIN [Table_Name_02]
ON [Table_Name_01].[Fild_Name_01] = [Table_Name_02].[Fild_Name_02];
To Update Records
To Update Field_Name_01 of Record where Field_Name_02 is'XXXXXX' to'Y'
UPDATE [Table_Name] SET [Field_Name_01] = 'Y' where [Field_Name_02] = 'XXXXXX';
To Insert new Records
To Insert new Record with Field_Name_01 and Field_Name_02'
INSERT INTO [Table_Name] (Field_Name_01,Field_Name_02)
VALUES('X_001', 'Y_001'),
('X_002', 'Y_002'),
('X_003', 'Y_003');
To Delete Records
To Delete Records with Field_Name_01 = 'X'
DELETE FROM [Table_Name] WHERE Field_Name_01 = 'X'
To Insert Field
To Insert Field_Name in Table_Name
ALTER TABLE [Table_Name] ADD [Field_Name] [Field_Type]
To Delete Field
To Delete Field_Name in Table_Name
ALTER TABLE [Table_Name] DROP [Field_Name]
To Modify Field Name
To Modify Field Name from Field_Name_01 to Field_Name_02
ALTER TABLE [Table_Name] CHANGE [Field_Name_01] [Field_Name_02]
To Modify Field Type
To Modify Field Type to Field_Type
ALTER TABLE [Table_Name] MODIFY [Field_Name] [Field_Type]