UNIT1---INTRODUCTION TO MYSQL

MYSQL INTRODUCTION


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 )
INSERT DATA INTO MYSQL
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,...)
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(stringfrom_stringnew_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 ;

Comments

Post a Comment