python basis of a database acquaintance day41

Day57

Pledge:
do not look at the video lesson 1.
Synopsis 2. notes
finishing school contents 3. Course

curriculum:
MySQL
Web framework:
- Python
- the front
- MySQL
project combat:
- Simple CURD
- support system (blog + BBS + Admin)
- CMDB asset management
- CRM
- fortress machine
reptiles:
- Scrapy
other:
...

MySQL

stand-alone program (own DB)

stand-alone program (public DB)

MySQL: is a software for managing files
- server software
- socket server
- local file operations
- command parsing the SQL statement []
- Client software (variety)
- socket client
to send commands -
- parse command [ SQL statements]

PS:
- the DBMS database management system
- SQL statements

skills:
- installation services and client
- connection
- learning SQL statement rule; instruct the server to do any of the following

Other similar software:
relational database: sqllite, db2, oracle, access , sql server MySQL
non-relational database: MongoDB, redis

1. MySQL install

Windows:
Executable
little point
compression package
placed in any directory
initialization
server: E: \ wupeiqi \ MySQL-5.7.16-Winx64 \ MySQL-5.7.16-Winx64 \ bin \ mysqld --initialize in the insecure-
# username root password: empty
start the server:
E: \ wupeiqi \ MySQL-5.7.16-Winx64 \ MySQL-5.7.16-Winx64 \ bin \ mysqld \ mysqld

client connections:
E: \ wupeiqi \ MySQL-5.7.16 -winx64 \ mysql-5.7.16-winx64 \ bin \ mysqld \ mysql -u root -p

send instructions:
Show Databases;
Create Database DB1;

configuration environment variables:
E: \ wupeiqi \ MySQL-5.7.16-Winx64 \ MySQL Winx64--5.7.16 \ bin
mysqld

Windows service:
E: \ wupeiqi \ MySQL-5.7.16-Winx64 \ MySQL-5.7.16-Winx64 \ bin \ mysqld --install
NET Start MySQL

E: \ wupeiqi \ MySQL-5.7.16-Winx64 \ MySQL-5.7.16-Winx64 \ bin \ mysqld --remove

NET Start MySQL
NET STOP MySQL

2. About Connection

folder [database]
file [] table
rows [row ]
data line
data line

connection:

default: user root


Show databases;

use database name;

Show the tables;

the SELECT * from table name;

the SELECT name, Age, the above mentioned id from table name;

MySQL database user tables
use MySQL;
the SELECT user, Host from user ;

Create a user:
the Create the User 'alex'@'192.168.1.1' IDENTIFIED by '123123';
the Create the User 'alex'@'192.168.1.%' IDENTIFIED by '123123';
the Create the User 'alex' @ '%' IDENTIFIED by '123123';
authorized:
permissions man

Grant the SELECT, INSERT, ON db1.t1 Update to 'alex' @ '%';
Grant All privileges ON db1.t1 to 'alex' @ '%';

REVOKE privileges ON db1.t1 All from 'Alex' @ '%';

the DBA: username password


3. Learn the rules of SQL statements

Operation folder
Create DB2 Database;
Create default DB2 Database charset UTF8; *****
Show Databases;
drop DB2 Database;

manipulate files
Show Tables;
Create Table T1 (ID int, char name (10)) = default charset UTF8;
Create T1 Table (int ID, name char (10)) = InnoDB Engine default charset = UTF8;
Create Table T3 (int AUTO_INCREMENT ID, name char (10)) = InnoDB Engine default charset = UTF8; *****

Create Table T1 (
column name type null,
column name type Not null,
column name type Not null AUTO_INCREMENT Primary Key,
ID int,
name char (10)
) Engine = InnoDB default charset = UTF8;
# InnoDB support transactional, atomic operations
# MyISAM MyISAM

AUTO_INCREMENT said: increment
primary key: indicates constraint (repeats not and can not be empty); accelerated lookup
not null: not null
data types:

numeric:
tinyint
int
BIGINT

FLOAT
0.00000100000123000123001230123
DOUBLE
0.00000000000000000000100000123000123001230123
0.00000100000123000000000000000
decimal
0.1

String:
Fast char (10) speed ()
the root
the root
varchar (10) to save space
the root
the PS: create a table to put forward a fixed length column of

text

upload files:
file storage hard
db surviving path
time type
DATETIME

enum
SET


Create table T1 (
ID int Not null Signed AUTO_INCREMENT Primary Key,
NUM decimal (10 5),
name char (10)
) Engine = InnoDB default charset = UTF8;

empty table:
Delete from T1;
TRUNCATE Table T1;
delete tables:
drop Table T1;

action file contents
data is inserted:
INSERT INTO T1 (ID, name) values (. 1 , 'alex');
delete:
delete from T1 WHERE ID <. 6
Review:
Update T1 SET Age = 18 is;
Update T1 SET Age = 18 is WHERE Age =. 17;
see data:
SELECT * from T1;

foreign key:

Create Table UserInfo (
int Primary Key AUTO_INCREMENT UID,
name VARCHAR (32),
DEPARTMENT_ID int,
xx_id int,
constraint fk_user_depar Foreign Key (DEPARTMENT_ID) Color References (ID)
) = InnoDB Engine default charset = UTF8;

Table Department Create (
ID BIGINT AUTO_INCREMENT Primary Key,
title char (15)
Engine InnoDB default = charset = UTF8);
InnoDB atomic operation

today reference blog content:
http://www.cnblogs.com/wupeiqi/articles/5713315.html
Job :
http://images2015.cnblogs.com/blog/425762/201608/425762-20160803224643778-2071849037.png
http://www.cnblogs.com/wupeiqi/articles/5729934.html














 

 

 
















Guess you like

Origin www.cnblogs.com/wang-tan/p/11565149.html