MySQL database basics of MySQL_01, mysql_01mysql
1. operate databases through SQL (Structured Query Language:
DDL: Data Definition Language, database creation, table creation, and selection;
DML: data operation language to add, delete, and modify data;
DQL: Data Query Language for data query;
DCL: Data Control Language, authorization and permission revocation;
2. database connection:
Mysql-uroot or mysql-uroot-p password;
SQL statements are case-insensitive and end with a semicolon by default;
3. database:
① Create database: create database db_name;
Create a database if it does not exist:
Create database if not exists db_name;
② Query all DATABASES on the current server: show databases;
③ Open the specified database: USE db_name;
④ Obtain the currently opened DATABASE: select database ();
⑤ Delete a DATABASE: drop database db_name;
If yes:
Drop database if exists db_name;
4. data table:
① CREATE a data TABLE: create table tbl_name (field Name field type [constraints]);
② View the data table in the current database: show tables;
③ View the data table structure: DESC tbl_name;
④ Delete a specified data TABLE: drop table tbl_name;
5. MySQL Data Type:
① INTEGER: tinyint --- 128 ~ 127 or 0 ~ 25-1 bytes;
Int --- 2.1 billion ~ 2.1 billion or 0 ~ 4.2 billion -- 4 bytes;
② Float: float (M, D) -- M: total length; D: decimal places;
③ String: char () -- fixed-length string; varchar () -- variable-length string;