Explain how to create database and tables and how to insert update and select records in phpmyadmin in WAMP server step by step with Example

Hello brothers, welcome to master arts.

Today we learn about database creation in phpmyadmin. Hindi me hi sikhate hai kya bolate ho ? Dosto, aap sap phpmy admin ke bare me to jante hi honge. Chalo aaj me batata hu aapko ki database kaise create karate hai.

Agar aapane nahi pada to yaha se sikh sakte hai. kaise phpmyadmin kholana hai. To aap browser me localhost likhe waha heder me aapko phpmyadmin mill jayega. Ager xamp on hai to. Agar aapko database creat karna hai to simple new pe click karke database bana de.

Create database

Database name wale box me database a name likh ke create kar de database ban jayega.

Create Tables

Jaisa ki aap uper left side bar me mera mydb name se database create hua hai usake + sign pe click karenge to aapko new likha milega usape click karke aap table create kar sakte hai. aap usape click karenge to kuch aisa page khulega.

Apako char column ke box dilkhenge. aap or column bhi add kar sakte hai table me uper add wale se. koi bhi table banaye pehala column ID ka banaye. to first box me ID likho or A_I wala box pe click karde A_I ka matlab hai auto increment. ab secon box me aap apane hisab se name dede jo jo requirement ho.

text limited field hai to type me varchar select kare lanth me aap 1 se 256 ki limit set kar sakte hai. or agar 256 se jyada insert karna chahte hai to TEXT select karle type lanth blank chod de. by default koi value add karna chahte hai to aap default me set kar sakte hai. or NULL allow nahi larna to NULL pe tik na kare. ab create karle table go pe click karke.

ab table create kar diya or aapko ek or column insert karna hai ya koi column nikalna hai to? iska bhi tarika hai dosto

Create Database

CREATE DATABASE testDB;

Create Index

CREATE INDEX idx_lastname
ON Persons (LastName);

Create Table

CREATE TABLE Persons (
    PersonID int,
    LastName varchar(255),
    FirstName varchar(255),
    Address varchar(255),
    City varchar(255)
);

insert new column

ALTER TABLE table_name ADD COLUMN column_name varchar(256); // run this quarry in SQL first open database then

insert new column with default value

ALTER TABLE table_name ADD COLUMN column_name bit(1) DEFAULT 0; // run this quarry in SQL first open database then

Delete Drop column

ALTER TABLE table_name DROP COLUMN column_name; // run this quarry in SQL first open database then

Delete quarry

DELETE FROM table_name WHERE user_name='user'; // run this quarry in SQL first open database then

SQL PRIMARY KEY on CREATE TABLE

CREATE TABLE Persons (
    ID int NOT NULL,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int,
    PRIMARY KEY (ID)
);

SQL FOREIGN KEY on CREATE TABLE

CREATE TABLE Orders (
    OrderID int NOT NULL,
    OrderNumber int NOT NULL,
    PersonID int,
    PRIMARY KEY (OrderID),
    FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)
);

SQL Server Data Types

String data types:

CHAR(size)A FIXED length string (can contain letters, numbers, and special characters). The size parameter specifies the column length in characters – can be from 0 to 255. Default is 1
VARCHAR(size)A VARIABLE length string (can contain letters, numbers, and special characters). The size parameter specifies the maximum column length in characters – can be from 0 to 65535
BINARY(size)Equal to CHAR(), but stores binary byte strings. The size parameter specifies the column length in bytes. Default is 1
VARBINARY(size)Equal to VARCHAR(), but stores binary byte strings. The size parameter specifies the maximum column length in bytes.
TINYBLOBFor BLOBs (Binary Large OBjects). Max length: 255 bytes
TINYTEXTHolds a string with a maximum length of 255 characters
TEXT(size)Holds a string with a maximum length of 65,535 bytes
BLOB(size)For BLOBs (Binary Large OBjects). Holds up to 65,535 bytes of data
MEDIUMTEXTHolds a string with a maximum length of 16,777,215 characters
MEDIUMBLOBFor BLOBs (Binary Large OBjects). Holds up to 16,777,215 bytes of data
LONGTEXTHolds a string with a maximum length of 4,294,967,295 characters
LONGBLOBFor BLOBs (Binary Large OBjects). Holds up to 4,294,967,295 bytes of data
ENUM(val1, val2, val3, …)A string object that can have only one value, chosen from a list of possible values. You can list up to 65535 values in an ENUM list. If a value is inserted that is not in the list, a blank value will be inserted. The values are sorted in the order you enter them
SET(val1, val2, val3, …)A string object that can have 0 or more values, chosen from a list of possible values. You can list up to 64 values in a SET list

Numeric data types:

Data typeDescription
BIT(size)A bit-value type. The number of bits per value is specified in size. The size parameter can hold a value from 1 to 64. The default value for size is 1.
TINYINT(size)A very small integer. Signed range is from -128 to 127. Unsigned range is from 0 to 255. The size parameter specifies the maximum display width (which is 255)
BOOLZero is considered as false, nonzero values are considered as true.
BOOLEANEqual to BOOL
SMALLINT(size)A small integer. Signed range is from -32768 to 32767. Unsigned range is from 0 to 65535. The size parameter specifies the maximum display width (which is 255)
MEDIUMINT(size)A medium integer. Signed range is from -8388608 to 8388607. Unsigned range is from 0 to 16777215. The size parameter specifies the maximum display width (which is 255)
INT(size)A medium integer. Signed range is from -2147483648 to 2147483647. Unsigned range is from 0 to 4294967295. The size parameter specifies the maximum display width (which is 255)
INTEGER(size)Equal to INT(size)
BIGINT(size)A large integer. Signed range is from -9223372036854775808 to 9223372036854775807. Unsigned range is from 0 to 18446744073709551615. The size parameter specifies the maximum display width (which is 255)
FLOAT(sized)A floating point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter. This syntax is deprecated in MySQL 8.0.17, and it will be removed in future MySQL versions
FLOAT(p)A floating point number. MySQL uses the p value to determine whether to use FLOAT or DOUBLE for the resulting data type. If p is from 0 to 24, the data type becomes FLOAT(). If p is from 25 to 53, the data type becomes DOUBLE()
DOUBLE(sized)A normal-size floating point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter
DOUBLE PRECISION(sized) 
DECIMAL(sized)An exact fixed-point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter. The maximum number for size is 65. The maximum number for d is 30. The default value for size is 10. The default value for d is 0.
DEC(sized)Equal to DECIMAL(size,d)

Hope understand everithing about database, we will explain insert update delete etc in next lession.

happy coding.