UNIT1---INTRODUCTION TO MYSQL
MYSQL
INTRODUCTION
INSERT DATA INTO MYSQL
MySQL is an open source,
fast reliable, and flexible relational database management system, used with
PHP.
MySQL is a fast,
easy-to-use RDBMS being used for many small and big businesses.
MySQL is developed,
marketed and supported by MySQL AB, which is a Swedish company.
MYSQL DATA TYPES
BIT.
CHAR.
DATETIME.
DECIMAL.
ENUM.
JSON.
TIME.
TIMESTAMP.
CREATE A MYSQL TABLE
A database table has its own unique name and consists of
columns and rows.
The CREATE TABLE statement is used to create a table in MySQL.
Ex:
CREATE
TABLE MyGuests (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50),
reg_date TIMESTAMP )
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50),
reg_date TIMESTAMP )
After a database and
a table have been created, we can start adding data in them.
Here are
some syntax rules to follow:
String values inside
the SQL query must be quoted
Numeric values must not be quoted
The word NULL must
not be quoted
Ex:
INSERT
INTO table_name (column1, column2,
column3,...)
VALUES (value1, value2, value3,...)
VALUES (value1, value2, value3,...)
SELECT
DATA FROM A MYSQL
The SELECT statement is used to select data from one or
more tables.
we can use the * character to select ALL columns from a
table.
EXAMPLE
SELECT * FROM table_name
;
Replace Data From a MySQL
The
REPLACE() function
replaces all occurrences of a substring within a string,
with a new substring.
EXAMPLE
REPLACE(string, from_string, new_string)
DELETE DATA FROM A MYSQL
The DELETE statement
is used to delete records from a table:
DELETE
FROM table_name
WHERE some_column = some_value
Update Data In a MySQL
The UPDATE statement
is used to update existing records in a table:
UPDATE table_name
SET
column1=value, column2=value2,...
WHERE some_column=some_value
;
Good
ReplyDeleteExcellent.....
Keep post.....