Use the source command in MySQL to import SQL files

Source: Internet
Author: User
Tags dname

MySQL source command import SQL File

==============================================

Small Example

The mytest_emp_dept. SQL file contains the following content:

Create Table EMP (Eid int primary key auto_increment, ename varchar (20) not null, esex varchar (10), deptid int not null );

Create Table dept (deptid int primary key auto_increment, dname varchar (20) not null, daddress varchar (200 ));

Insert into EMP (ename, esex, deptid) values ('chris ', 'M', 1), ('edge', 'M', 1), ('Kelly ', 'w', 2), ('maryse', 'w', 2 );

Insert into dept (dname, daddress) values ('development', 'beijing'), ('account', 'shanghai ');

Select ename, esex, dname, daddress from EMP, DEPT where EMP. deptid = Dept. deptid order by ename;

 

==============================================

1

E:/Wamp/bin/MySQL/mysql5.5.8/bin> mysql-H localhost-u root-P

 

2

Use PAA; (database )!

3

 

 

The command line for importing SQL statements is as follows:

Source "pathname" +/mytest_emp_dept. SQL

 

==============================================

 

The effect is as follows:

 


 

========================================================== ====================================

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.