久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

MySQL怎么批量導(dǎo)入數(shù)據(jù)優(yōu)化

139次閱讀
沒有評論

共計 2859 個字符,預(yù)計需要花費(fèi) 8 分鐘才能閱讀完成。

這篇文章將為大家詳細(xì)講解有關(guān) MySQL 怎么批量導(dǎo)入數(shù)據(jù)優(yōu)化,文章內(nèi)容質(zhì)量較高,因此丸趣 TV 小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關(guān)知識有一定的了解。

–MyISAM 表
mysql show create table test\G
*************************** 1. row ***************************
       Table: test
Create Table: CREATE TABLE `test` (
  `id` int(11) NOT NULL,
  `last_name` char(30) NOT NULL,
  `first_name` char(30) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `name` (`last_name`,`first_name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

mysql show keys from test;
+——-+————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+——-+————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+
| test  |          0 | PRIMARY  |            1 | id          | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| test  |          1 | name     |            1 | last_name   | A         |        NULL |     NULL | NULL   |      | BTREE      |         |               |
| test  |          1 | name     |            2 | first_name  | A         |        NULL |     NULL | NULL   |      | BTREE      |         |               |
+——-+————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+
3 rows in set (0.00 sec)

mysql alter table test disable keys;
Query OK, 0 rows affected (0.00 sec)

mysql  load data infile /var/lib/mysql-files/test_out.txt into table test charset gbk fields terminated by , enclosed by
Query OK, 5 rows affected (0.02 sec)
Records: 5  Deleted: 0  Skipped: 0  Warnings: 0

mysql alter table test enable keys;
Query OK, 0 rows affected (0.00 sec)

–InnoDB 表
導(dǎo)入的數(shù)據(jù)按照主鍵的順序排列;

將 unique_checks 參數(shù)置為 0;
mysql show variables like %unique%
+—————+——-+
| Variable_name | Value |
+—————+——-+
| unique_checks | ON    |
+—————+——-+
1 row in set (0.01 sec)

mysql set unique_checks = 0;
Query OK, 0 rows affected (0.10 sec)

mysql show variables like %unique%
+—————+——-+
| Variable_name | Value |
+—————+——-+
| unique_checks | OFF   |
+—————+——-+
1 row in set (0.00 sec)

mysql  load data infile /var/lib/mysql-files/test_out.txt into table test charset gbk fields terminated by , enclosed by
Query OK, 5 rows affected (0.00 sec)
Records: 5  Deleted: 0  Skipped: 0  Warnings: 0

將 autocommit 參數(shù)設(shè)為 0

mysql show variables like autocommit
+—————+——-+
| Variable_name | Value |
+—————+——-+
| autocommit    | ON    |
+—————+——-+
1 row in set (0.00 sec)

mysql set autocommit = 0;
Query OK, 0 rows affected (0.00 sec)

mysql show variables like autocommit
+—————+——-+
| Variable_name | Value |
+—————+——-+
| autocommit    | OFF   |
+—————+——-+
1 row in set (0.00 sec)

mysql load data infile /var/lib/mysql-files/test_out.txt into table test charset gbk fields terminated by , enclosed by
Query OK, 5 rows affected (0.00 sec)
Records: 5  Deleted: 0  Skipped: 0  Warnings: 0

關(guān)于 MySQL 怎么批量導(dǎo)入數(shù)據(jù)優(yōu)化就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-07-27發(fā)表,共計2859字。
轉(zhuǎn)載說明:除特殊說明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 金华市| 兴仁县| 安岳县| 永福县| 濮阳市| 文水县| 高邮市| 海宁市| 建宁县| 益阳市| 登封市| 揭东县| 凤城市| 河间市| 大竹县| 太仓市| 红原县| 略阳县| 马鞍山市| 上蔡县| 邓州市| 曲阳县| 城固县| 湖北省| 米易县| 十堰市| 肇东市| 久治县| 海林市| 威信县| 迁西县| 五大连池市| 永平县| 云南省| 高碑店市| 宁夏| 涟水县| 伊金霍洛旗| 鄢陵县| 江都市| 新野县|