1. Create a database, a table, and an instance for inserting data.
Drop database if exists school; -- delete if school exists
Create Database school; -- create a database School
Use school; -- open the library school
Create Table teacher -- Create Table teacher
(
Id integer auto_increment not null primary key,
Name varchar (10) Not null
); -- End of table Creation
Insert into teacher values (null, 'T ');
Insert into teacher values (null, 'J ');
It is inconvenient to debug commands in DOS. You can write the preceding commands into a file named School. SQL, then copy it to c: \, and type the following command in the DOS window: mysql-uroot-P password <C:/school. SQL.
Ii. Import and export of. SQL files in windows.
DOS window: Start-> Run-> cmd
Import to: mysql-uroot-proot <C:/school. SQL
Export to: mysqldump-uroot-proot school> C:/school. SQL
Iii. Data Backup (the command is executed in the DOS window ):
1. Back up the database: (back up the database School)
Mysqldump-uroot-proot school> C:/school. SQL
2. Import the backup data to the database: (import back to the school database)
Mysql-uroot-proot school <C:/school. SQL
Note: At this time, the database school already exists.
Note: Another method is to enter the MySQL Database Console, use school, and then use the source commandSource C:/school. SQLYou can.
4. Import text data to the MySQL database.
1. Text data must conform to the corresponding format: field data is separated by the tab key, and the null value is replaced by \ n.
For example, a file named teacher.txt contains the following content:
\ N w
\ N h
2. Data Import commandLoad data local infile "C:/teacher.txt" into Table teacher;
Note: In the MySQL Command window, use the use command to open the database where the table is located.