MySql My Notes

Create and Use DataBase in MySql

Type this code for creating database in MySql

create database adeel;

Type this code for using by default database.
use adeel;

Create Table

create table TestAdeel (
id int,
FirstName varchar(255),
LastName varchar(255),
FatherName varchar(255),
Address varchar(255)
);

Insert into Table Data

insert into testadeel (id, FirstName, LastName, FatherName, Address)
values
(1, ‘Adeel’, ‘Ahmad’, ‘Khalil’, ‘Lahore’);

insert into multiple values in all columns

If you want to put data in all columns then no need to mention all columns name. As you can see below. 

insert into testadeel
values
(2, ‘Ade’, ‘Ahad’, ‘Khala’, ‘Lahore’),
(3, ‘Adee’, ‘Ahad’, ‘Khala’, ‘Lahore’);

insert into Specific folder data

insert into testadeel (FirstName)
values
(‘Ade’),
(‘Lahore’);

Select command

Select command is used to select and show the table data. 

Select all:
SELECT FROM tableName;

Select specific record from specific column:

column is selected which you want to see and can call from specific column.

select FName from class where id=’2′;

 

Delete Table or database:

For Table
DROP table tableName;

for database
DROP database databaseName;

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.