Use of MySQL (on)

Source: Internet
Author: User
Tags creative commons attribution square root time and date

Database-mysql The default super Administrator

User name: Root

Password: root



The localhost 127.0.0.1 all indicate that the native

Identifier
    1. Pk:primary Key (column is part of a PK) primary key
    2. Nn:not Null (column is nullable) non-null
    3. Uq:unique (column is part of a unique key) unique
    4. B:binary binary (larger binary data than text)
    5. un:unsigned integer
    6. Zf:zero fill 0, such as content 1 int (4), is displayed as 0001.
    7. Ai:auto Increment (the column is auto incremented when rows are inserted) self-increment

      Create a database

      In schemas, right click creat schemas. Enter the name of the database and choose the encoding format: Utf8mb4-default collation (Chinese supported).

      Create a table

      You can right-click Create table on the database.

      Inserting data

      Table Set Primary key, when viewing a table * Can insert data, modify Insert after click Apply (MySQL is not case-sensitive)

FOREIGN Key Association

A foreign Keys can be associated by setting up a page in a table

    1. Foreign Key Name: Pick up a proper name for yourself
    2. Referenced Table: Selecting a Database
    3. Select the corresponding column column: columns for the current table, R.. The column that corresponds to the database selected in Column:2.
    4. Foreign keys can be one-to-one, one-to-many, many-to-many.
Using the MySQL console
    1. Open the MySQL console (enter the password entry)

      A. You can find the MySQL console directly in the Start menu to open

      B. In the mysql5.7 folder, locate the drag-in Cmd followed by the-u user name-p password
    2. View all database commands: show databases;
    3. View database table commands: 1, use database name; 2, show tables;
    4. Creating database command: Create database name;
    5. Delete Database command: drop database name;
    6. Help command: helping;
    7. Exit command: Quit;
The use of SQL statements to increase and revise the search
    1. Using the database you want to use
    2. Create a table

      create table tablename(        col_name type not null auto_increment,col_name type default,primary key(col_name
    3. View table structure command: DESC table name;
    4. Delete Table command: drop table name;
    5. View table commands: Show tables;

Insert Table
insert into tablename(col_name,col_name,col_name)values(value1,value2,value3);
    1. View all data commands for a table: SELECT * from table name;
Modify Table
update tablename set    col_name = value,    col_name = value  where condition;  {条件,如果不加那么会修改所有相同列名的数据}
Delete table Data
 delete from tablename where condition; {如果不跟条件就会删除所有数据}
Find sort
    1. SELECT * Form table name limit 2;{query first two data}
    2. SELECT * Form table name limit 2,3;{Remove the first 2, from the third article to look back 3}
    3. SELECT * Form column name from table name where condition;
    4. Example: SELECT * FROM MyTable the order by ID; {Sort by id}
    5. ID followed by DESC for reverse order
    6. ! Conditions can be followed by multiple. Ex

      select * from mytable order by id,nsme desc;
Querying static values
    1. select ‘some thing’; query a static record
    2. select 1+1; Query Results
    3. select now(); Fetch the current time and date
    4. asModifying a table header
    5. select curdate(); Query the current date
    6. select curtime(); Query the current time
    7. select pi(); The value of π
    8. select mod(30,10); Seeking redundancy
    9. select sqrt(24); square root
    10. select round(x,y)Rounding retains y decimal places
    11. select floor(); Direct
    12. can go to MySQL official website to find so some functions functions and Operators
Backup and recovery of databases

1. Backup
Click the data export-in the navigation bar to select the database-export to Dump Project folder settings location-start Export (packed out of a folder per table)

Export to self-contained file select location-from folder name (packaged into a single folder)

2. Recovery

Click on the navigation bar Data import-Recovery There are two ways to make a backup choice-find the database you want to import-default the Target Schema (a new database can also be selected to hold the recovered data)-start Import

Recommended Sites

W3school


This work is licensed by A_aiting using the Creative Commons Attribution-NonCommercial 4.0 International license Agreement.

Use of MySQL (on)

Related Article

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.