MySQL database basics of MySQL_01, mysql_01mysql

Source: Internet
Author: User

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.