当前位置:网站首页>Day 6 summary & database operation
Day 6 summary & database operation
2022-07-26 08:52:00 【xbxbgk】
1. Classification of database
Relational type :mysql,oracle,sqllite( The mobile terminal comes with ,django Default ),sql server
Non relational :redis,mongoDB
2.mysql install
Guarantee : Check whether the computer has been installed before installation , uninstall mysql5.5 edition ,django Use 5.5 above
A database is used to store data
library / surface Library similar directory The table is similar to the table of contents excle
3. Basic knowledge
sql sentence
Dedicated to manipulating libraries and tables a key
sql The classification of sentences
Database query language (DQL) select
Database operation language (DML) delete update insert
Database definition language (DDL) establish 、 Delete 、 Modify the structure of the table create、drop、alter
Field type
Integers :int/bigint
decimal :float/double
character string :char/varchar
Time :date/time/datetime
Field constraints
null Can be null
not null Can't be empty
default The default value is
primary key Primary key
auto_increment Self increasing
charset Set character set
4.DDL Database definition language
Create a library
create database Library name CHARSET=utf8;
Delete Library
DROP DATABASE Library name ;
The statement to query the created library
show create DATABASE Library name ;
Use the library
use Library name
Create table
create table Table name ( Field type length , Field type length )
Delete table
drop table Table name
Query the statement that creates the table
show create table Table name ;
The structure of the query table
desc Table name
Modify table structure
newly added :alter table Table name add Field name type length ;
modify :alter table Table name MODIFY COLUMN Field name type length ;
Delete : alter table Table name drop Field name ;
5.DML Database operation language
newly added
insert into Table name value ( value , value , value , value ), ( value , value , value , value )
modify
UPDATE Table name set Field = The new value where Conditions Modify the data of a field
UPDATE Table name set Field = The new value , Field = The new value where Conditions Modify the data of two fields
Delete
delete from Table name where Conditions Delete specified data
delete from Table name Delete all data
6.DQL Database query language
Query all the data :select * from Table name ;
Query the data of the specified field :select Field name , Field name from Table name ;
Comparison operator : > >= < <=
select * from Table name where Field > value ;
Logical operators :and or not
SELECT * from student where sex=' Woman ' and score>92
SELECT * from student where sex=' Woman ' or score>92
SELECT * from student where sex=' male '
SELECT * from student where not sex=' Woman '
keyword -- Fuzzy query
select * from Table name where Field like '% Fuzzy data %'
eg:%: Match all data _: To match a character
Range queries 80~95
stay ... Between stay .... in
SELECT * from student where score BETWEEN 80 and 95;
SELECT * from student where id in(1,3,5,7)
Sort
select * from Table name order by Field desc( In reverse order ), Field desc( In reverse order )
grouping
function :count() Query quantity sum() and max() The lion min() Take the minimum avg() The average
select count(*) from Table name group by Field having Conditions
eg:having similar where But in general where It cannot be used with functions later ,having Can often and group by Use it together
Pagination
limit Start index position , The number of bars displayed
SELECT * from student LIMIT 0,3
Homework 1

Homework 2

Homework 6

Homework 7

Additions and deletions

边栏推荐
- Xtrabackup appears' flush no '_ WRITE_ TO_ BINLOG TABLES‘: 1205 (HY000) Lock wait timeout exceeded;
- Oracle 19C OCP 1z0-082 certification examination question bank (30-35)
- 数据库操作技能7
- 03异常处理,状态保持,请求钩子---04大型项目结构与蓝图
- 【FreeSwitch开发实践】自定义模块创建与使用
- Web概述和B/S架构
- Human computer interaction software based on C language
- TypeScript版Snowflake主键生成器
- C # use npoi to operate Excel
- Foundry tutorial: writing scalable smart contracts in various ways (Part 1)
猜你喜欢

Study notes of automatic control principle -- dynamic model of feedback control system

Leetcode and query question summary

1、 Redis data structure

Set of pl/sql -2

Study notes of automatic control principle --- stability analysis of control system

有限元学习知识点备案

Neo eco technology monthly | help developers play smart contracts

Sub Chocolate & paint area

Mycat2 sub database and sub table

Mysql8 dual master and dual slave +mycat2 read / write separation
随机推荐
Alphabetic string
pl/sql之集合
P3743 Kotori's equipment
Excel find duplicate lines
Analysis on the query method and efficiency of Oracle about date type
CIS 2020 - alternative skills against cloud WAF (pyn3rd)
六、品达通用权限系统__pd-tools-log
Mysql database connection / query index and other common syntax
Oracle 19C OCP 1z0-082 certification examination question bank (51-60)
合工大苍穹战队视觉组培训Day6——传统视觉,图像处理
[suggestions collection] summary of MySQL 30000 word essence - locking mechanism and performance tuning (IV) [suggestions collection]
What are the differences in the performance of different usages such as count (*), count (primary key ID), count (field) and count (1)? That's more efficient
基于C语言设计的换乘指南打印系统
SSH,NFS,FTP
03 exception handling, state keeping, request hook -- 04 large project structure and blueprint
Kept dual machine hot standby
Introduction to AWD attack and defense competition
keepalived双机热备
Oracle 19C OCP 1z0-082 certification examination question bank (24-29)
【加密周报】加密市场有所回温?寒冬仍未解冻 盘点上周加密市场发生的重大事件