Now first Go to http://localhost/phpmyadmin/
SQL Queries:
For creating a database:
CREATE DATABASE database_name;
Create Table:
CREATE TABLE table_name (
column1 data_type(size), column2 data_type(size), column3 data_type(size), ....
);
Example Query:
This query will create a table named Students with three columns, ROLL_NO, NAME and SUBJECT.
CREATE TABLE Students (
ROLL_NO int(3) PRIMARY KEY, NAME varchar(20),
SUBJECT varchar(20) );
Inserting data in the table:
INSERT INTO table_name
VALUES (value1, value2, value3, ...);
Insert Data Only in Specified Columns
INSERT INTO Customers (CustomerName, City, Country) VALUES ('Cardinal', 'Stavanger', 'Norway');
Create Table Using Another Table
A copy of an existing table can also be created using CREATE TABLE.
The new table gets the same column definitions. All columns or specific columns can be selected.
CREATE TABLE new_table
AS (SELECT column_1, column2, ... column_n FROM old_table);
Deleting a Table:
DROP TABLE table_name
Exercise:
Create the following table:
What’s the difference between CHAR and VARCHAR?
The short answer is: VARCHAR is variable length, while CHAR is fixed length.