当前位置:网站首页>Mysql---- import and export & View & Index & execution plan
Mysql---- import and export & View & Index & execution plan
2022-07-07 06:49:00 【An Li Jiu Ge】
Catalog
Preface
Last time I shared MySQL Function of , The content of this sharing is , Import and export 、 View 、 Index and execution plan
One 、 Import and export
1. Using tools , similar Sqlyog、Navicat Wait to import and export data .
1.1 export (Navicat)
Select the file save path
1.2 Import
Select the table , Select run SQL file
Choose SQL file
2. Use mysqldump Import and export
2.1 export
2.1.1 Export table data and table structure
mysqldump -u user name -p password Database name > Database name .sql( This name is casually called )#/usr/local/mysql/bin mysqldump -uroot -pabc >abc.sql
After typing enter, you will be prompted to output the password
notes : The exported data is in mysql Of bin Under the table of contents2.2 Import
Be careful : First, create an empty database
mysql>create database abc;
2.2.1 Method 1
mysql>use abc; # Select database
mysql>set names utf8; # Set database encoding
mysql>source /home/abc/abc.sql; # Import data2.2.2 Method 2
mysql -u user name -p password Database name < Database name .sql
#mysql -uabc_f -p abc < abc.sql
3.LOAD DATA INFILEYou can go through first SELECT INTO OUTFILE The way , Export data to Mysql Of C:\ProgramData\MySQL\MySQL Server 5.5\data Under the table of contents , Re pass LOAD DATA INFILE Mode import .
1) select * from Table name into outfile '/ file name .sql';
2) load data infile '/ file name .sql' into table Table name ( Name 1,...);
Be careful : Authorization is required, otherwise it cannot be exported successfully
In our MySQL Under the installation directory of my.ini Authorization in document
Two 、 View
1. What is a view
1) A view is a virtual table , A table derived from one or more tables in a database .
2) The definition of view is stored in the database , There is no data stored in view , The data is stored in the original table .
3) When using views to query data , The database system will take the corresponding data from the original table .
2. The function of view1) Make the operation simple .
2) Increase data security .
3) Improve the logical independence of tables .3. Basic grammar
CREATE VIEW View name AS SELECT sentence ;Be careful : On the premise of successful view creation, duplicate columns cannot appear
3、 ... and 、 Indexes
1. What is index
An index is a combination of one or more columns in a database table , Its function is to improve the query speed of data in the table .
A catalogue similar to a book , Easy and fast positioning , Find the specified content .2. Advantages and disadvantages of index
advantage : Speed up data query .
shortcoming : The time to create and maintain indexes has increased , At the same time, it takes up hard disk space .3. Index classification
1) General index : Is the most basic index , It has no restrictions ;
Be careful : The corresponding column values of unique key indexes are not allowed to be the same
2) unique index : Similar to the previous normal index , The difference is that : The value of the index column must be unique , But you can have an empty value . If it's a composite index , The combination of column values must be unique ;
3) primary key : Is a special unique index , A table can only have one primary key , No null values are allowed ;
4) Composite index : An index created on multiple fields , Only the first field that created the index is used in the query criteria , Indexes are used . When using a composite index, follow the leftmost prefix set ;
Follow the leftmost segment matching principle
5) Full-text index : Use FULLTEXT Parameters can be set , Full text index can only be created in CHAR,VARCHAR,TEXT Type field on . The main function is to improve the speed of querying larger string types ; Only MyISAM The engine supports the index ,MySQL The default engine does not support ;mysql5.7+
Word segmentation is The Chinese / the people / republic
4. Create index
CREATE [UNIQUE|FULLTEXT] INDEX Index name ON Table name ( Field name [( length )][ASC|DESC])
5. Modify the index
ALTER TABLE Table name ADD [UNIQUE|FULLTEXT] INDEX Index name ( Field name [( length )][ASC|DESC])
6. Delete index
DROP INDEX Index name ON Table name
Four 、 Implementation plan
We import case data
explain select * from t_user u left join t_role r on u.roleid = r.roleid
explain select * from t_user u where u.roleid = (select roleid from t_role where rolename = ' Administrators ')
explain select * from t_user u left join t_role r on u.roleid = r.roleid
explain select * from t_user u right join t_role r on u.roleid = r.roleid
id The higher the priority, the higher
1、 like Key left cannot be added %
2、or The conditional column segment of a link cannot be a column segment without an index
3、 The data type of query criteria must be a value
4、 Avoid using !=
5、 Sorting will invalidate the index
6、 The leftmost paragraph implements the principle
边栏推荐
- C language interview to write a function to find the first public string in two strings
- MATLAB小技巧(30)非线性拟合 lsqcurefit
- 大促过后,销量与流量兼具,是否真的高枕无忧?
- 「运维有小邓」符合GDPR的合规要求
- 地质学类比较有名的外文期刊有哪些?
- 2018年江苏省职业院校技能大赛高职组“信息安全管理与评估”赛项任务书第二阶段答案
- 分布式id解决方案
- Navicat importing 15g data reports an error [2013 - lost connection to MySQL server during query] [1153: got a packet bigger]
- 隐马尔科夫模型(HMM)学习笔记
- 企業如何進行數據治理?分享數據治理4個方面的經驗總結
猜你喜欢
Comment les entreprises gèrent - elles les données? Partager les leçons tirées des quatre aspects de la gouvernance des données
Jetpack Compose 远不止是一个UI框架这么简单~
Abnova 膜蛋白脂蛋白体技术及类别展示
Redis (II) - redis General Command
[start from scratch] detailed process of deploying yolov5 in win10 system (CPU, no GPU)
服装门店如何盈利?
剑指offer-高质量的代码
Ha Qu projection dark horse posture, only half a year to break through the 1000 yuan projector market!
从零到一,教你搭建「CLIP 以文搜图」搜索服务(二):5 分钟实现原型
LM11丨重构K线构建择时交易策略
随机推荐
带你刷(牛客网)C语言百题(第一天)
Prompt for channel security on the super-v / device defender side when installing vmmare
屏幕程序用串口无法调试情况
2018年江苏省职业院校技能大赛高职组“信息安全管理与评估”赛项任务书第一阶段答案
请问如何查一篇外文文献的DOI号?
VIM mapping large K
SVN version management in use replacement release and connection reset
Jmeter 5.5版本发布说明
dolphinscheduler3.x本地启动
拼多多败诉:“砍价免费拿”侵犯知情权但不构成欺诈,被判赔400元
Etcd database source code analysis -- starting from the start function of raftnode
unity3d学习笔记
Answer to the first stage of the assignment of "information security management and evaluation" of the higher vocational group of the 2018 Jiangsu Vocational College skills competition
How to find the literature of a foreign language journal?
JWT 认证
Tkinter window selects PCD file and displays point cloud (open3d)
化工园区危化品企业安全风险智能化管控平台建设四大目标
如何给目标机器人建模并仿真【数学/控制意义】
ceres-solver和g2o性能比较
impdp的transform参数的测试