Database-mysql The default super Administrator
User name: Root
Password: root
The localhost 127.0.0.1 all indicate that the native
Identifier
- Pk:primary Key (column is part of a PK) primary key
- Nn:not Null (column is nullable) non-null
- Uq:unique (column is part of a unique key) unique
- B:binary binary (larger binary data than text)
- un:unsigned integer
- Zf:zero fill 0, such as content 1 int (4), is displayed as 0001.
Ai:auto Increment (the column is auto incremented when rows are inserted) self-increment
Create a databaseIn schemas, right click creat schemas. Enter the name of the database and choose the encoding format: Utf8mb4-default collation (Chinese supported).
Create a tableYou can right-click Create table on the database.
Inserting dataTable 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
- Foreign Key Name: Pick up a proper name for yourself
- Referenced Table: Selecting a Database
- Select the corresponding column column: columns for the current table, R.. The column that corresponds to the database selected in Column:2.
- Foreign keys can be one-to-one, one-to-many, many-to-many.
Using the MySQL console
- 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
- View all database commands: show databases;
- View database table commands: 1, use database name; 2, show tables;
- Creating database command: Create database name;
- Delete Database command: drop database name;
- Help command: helping;
- Exit command: Quit;
The use of SQL statements to increase and revise the search
- Using the database you want to use
Create a table
create table tablename( col_name type not null auto_increment,col_name type default,primary key(col_name
- View table structure command: DESC table name;
- Delete Table command: drop table name;
View table commands: Show tables;
Insert Table
insert into tablename(col_name,col_name,col_name)values(value1,value2,value3);
- 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
- SELECT * Form table name limit 2;{query first two data}
- SELECT * Form table name limit 2,3;{Remove the first 2, from the third article to look back 3}
- SELECT * Form column name from table name where condition;
- Example: SELECT * FROM MyTable the order by ID; {Sort by id}
- ID followed by DESC for reverse order
! Conditions can be followed by multiple. Ex
select * from mytable order by id,nsme desc;
Querying static values
select ‘some thing’
; query a static record
select 1+1
; Query Results
select now()
; Fetch the current time and date
as
Modifying a table header
select curdate()
; Query the current date
select curtime()
; Query the current time
select pi()
; The value of π
select mod(30,10)
; Seeking redundancy
select sqrt(24)
; square root
select round(x,y)
Rounding retains y decimal places
select floor()
; Direct
- 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)