Import CSV:
Copy Code code as follows:
Load data infile '/test.csv ' into table table_name
Fields terminated by ', ' optionally
Enclosed by ' "' escaped by '"
Lines terminated by ' \ r \ n '
Ignore 1 lines;
Guide CSV:
Copy Code code as follows:
SELECT * into outfile '/test.csv '
FIELDS terminated by ', ' optionally
Enclosed by ' "'
LINES terminated by ' \ n '
from table_name
Background management system is always millions of data export, using Excel export can not be implemented at all, Excel only supports 65536,2007 and 2010 is 1048576, so no matter which can not meet the requirements, CSV to meet the requirements, do not limit the number of records, But a lot of data if the one-time processing of the
Reprint: http://blog.csdn.net/huyanping/article/details/7068356Often encounter need to export data from the database to Excel file, with some open-source class library, such as Phpexcel, it is quite easy to implement, but the support of a lot of data is not good, it is easy to reach the PHP memory usage limit. The method here is to use the Fputcsv write CSV file method, directly to the browser output Excel
When writing a program, you need to import a large amount of data into the database. for example, test scores and phone books are generally stored in excel. when writing a program, you need to import a large amount of data into the database, for example, exam scores and phone books are generally stored in excel. in this case, we can export the excel file to a csv file and then import the data to the databas
This article describes how to export mysql data to csv files using the specified encoding in php. it involves php's skills in querying mysql and operating csv files. it has some reference value, for more information about how to export mysql data to a csv file, see the examp
This article describes how to export mysql data to csv files using the specified encoding in php. it involves php's skills in querying mysql and operating csv files. it has some reference value, for more information about how to export mysql data to a csv file, see the examp
Import and Export csv files
In work, you need to import csv file data to the database or export the database data as a csv file. The following is my simple implementation.
1
For
Sometimes, when writing a program, the background requires that a large amount of data be imported into the database. For example, the computer examination result query and phone book data are generally stored in excel, in this case, we can export the data to a csv file, and then use the following program to import data to the database in batches in the background.
The following is only the main program
To export data to Excel files into scientific notation questions:
Analysis: The CSV file exported by the program, when the field has a relatively long number of fields exist, in the use of Excel software to view the CSV file will become the form of scientific and technological law.In fact, this question is not related to what language to
MySQL imports and exports CSV files bitsCN.com
MySQL provides a tool for importing and exporting databases. However, sometimes we only need to import and export data from a single table, such as importing and exporting CSV files. in this case, you can use the MySQL automatic command to import and export data.
The
Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn how to export csv data. Thinkphp is usually used to process data, but the code is similar to the following code logic! Does not rely on any third-party class libraries
// Data ProcessingFunction exportData (){ $ Result = mysql_query ("select * from student ");$ Str = "name, gender, age \ n
Tags: Body username pos Mon database data God Test Exportmongoexport-d test-c Item--type=csv-f salary,city,workyear,companyshortname-o user.csvmongoexport-d test-c user--type=csv-f Tel,type,username-o user.csv-D represents the database-C Representative Table--type represents the exported format-F represents the name of the column that needs to be exported-O represents the exported file nameAfter execution,
I use PHP locally to export a database table of data into a CSV file, can be fully exported, the size can go to more than 800 K
And I have the same PHP program on the site to export the same data table, can only export 8k multi-data.
Try using Ini_set (' memory_limit ', ' 32M '); No, you can only
PHP Exports the CSV abstract class, calculates the total batches according to the total number of records and the number of records per batch, and loops the export. Avoid running out of memory problems.
ExportCSV.class.php
Demo
The above is the PHP export CSV abstract class content, more relevant content pleas
The first of these methodsIn the export interface, open the CSV customization option, tick"Remove carriage return line break in a field"OptionsphpMyAdmin version is 3.42.X version not see this optionThe second method ofUPDATECatalog_product_entity_textSET' Value '=REPLACE(REPLACE(' Value ',CHAR ( 10) ," ) ,char (13) , " ) Remove the database field carriage return characterMySQL
MySQL provides a tool for importing and exporting databases. However, sometimes we only need to import and export data from a single table, such as importing and exporting CSV files. In this case, you can use the MySQL Automatic Command to import and export data.
The export syntax is as follows:
SELECT * FROM [TABLE]
Using Stored Procedures to batch export data into multiple csv files (ORACLE) databases has the following table structure: user_info (user_id NUMBER primary key, user_name VARCHAR2 (200) not null, user_age VARCHAR2 (80 ), create_date DATE, create_order hour. /* ============================== Step 1: CREATE a TABLE =================================*/create table USER_INFO (USER_ID number primary key, USER_NA
Export csv data within three months in PHP. for example, I want to calculate the first day of three months ago to the last day of the month. nbsp; what should I do on the first day of three months? ------ solution ---------------------- select nbsp; * nbsp; fromtbl_namewhere nbsp; date nbsp; gt; nbsp; date_format (csv in PHP exports data within three month
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.