Use of files in database management

Source: Internet
Author: User


In database management, files are commonly used to read data (import) from text files: CSV (Comma Separated Values) files. The Comma-Separated Values are as follows: www.2cto.com [plain] M0001, Li Gang, 1976-01-05,1 M0002, Wang Er, 1955-01-15,1 M0003, Li Si, 1967-03-05,1 [SQL] LOAD DATA INFILE 'd: /myCodes/test. cvs 'into TABLE member fields terminated by ','; -- Note test. SELECT * into outfile 'd:/myCodes/out. cvs 'fields terminated by ',' FROM member; execute the SQL command stored in the file [SQL] SOURCE D:/myCodes/ Test. SQL -- SOURCE is not an SQL command, so there is no plus points at the end; mysql test-uroot-p-e "SOURCE D:/myCodes/test. SQL "-- test is the database name. You can write the preceding SQL statements into batch processing files, for example, [plain] mysql test-uroot-p-e" SOURCE D:/myCodes/test. SQL "pause saves the SQL Execution results to input devices such as the keyboard and mouse in the file, known as standard input, display, and other devices, and is a standard output. Standard input and standard output devices can be changed. Such changes are called redirection ). In the command window, [SQL] dir> D:/myCodes/redirect.txt dir> D: \ myCodes \ redirect.txt TYPE D: \ myCodes \ redirect.txt HELP TYPE MySQL, [SQL] mysql-uroot-p> D: \ myCodes \ log.txt TYPE D: \ myCodes \ log.txt mysql-uroot-p-e "SOURCE D:/myCodes/test. SQL "> D: \ myCodes \ log.txt USE the tee command to save the execution result of the SQL statement to the file [SQL] tee D:/myCodes/teeLog.txt USE home; SELECT * FROM customer; notee; EXIT; type d: \ myCodes \ teeLog.txt database backup and recovery operation to save the entire database to a file, called dump to restore the dump text file to the database, called Recovery (restore) [SQL] mysqldump-u root-p home> D: /myCodes/home_back. SQL -- default-character-set = utf8 mysqladmin-u root-p CREATE home1 mysql-u root-p home1 <D: /myCodes/home_back. SQL -- default-character-set = utf8

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.