Execute the SQL script in the MySQL command line.

Source: Internet
Author: User

Execute the SQL script in the MySQL command line.

This article mainly introducesMySQL Command LineThe following example shows how MySQL executes the script under the command line. Now let's start to introduce this process.

1. Write an SQL script and save it as book. SQL. The content is as follows::

1 use test; 2 3 create table book 4 5 (6 7 tisbn varchar (20) primary key, 8 9 tbname varchar (100), 10 11 tauthor varchar (30 ), 12 13 chubanshe varchar (40), 14 15 bookdate date, 16 17 bookpage int, 18 19 leixing varchar (20), 20 21 bprice float (6, 2) 22 23 ); 24 25 insert into book values ('20140901', 'java SE 9787115167408 programming Guide', 26 27 'wu Yafeng; JI Chao ', 28 29 'people's post and telecommunications Publishing House ', '1970-11-00', 2007, 30 31 'computer class', 874); 32 33 insert into book values ('20140901 ', 34 35 'proficient in Netbeans-Java Desktop, Web and enterprise-level Program Development details', 36 37 'wu Yafeng; Wang xinre', 38 39 'people's post and telecommunications Publishing House ', '2014-2-10', 2007, 40 41 'computer class', 587); 42 43 insert into book values ('20140901', 'high quality programming art ', 44 45' (Greece) Diomidis Spinellis ', 46 47 'people's publishing house', '2017-1-00 ', 2008, 48 49 'computer class', 384 ); 50 51 insert into book values ('123456', 'java programming ideology (version 9787111213826) ', 52 53' (US) Bruce Eckel', 54 55' Mechanical Industry Press ', '2014-06-0', 2007, 56 57 'computer class', 880); 58 59 insert into book values ('20140901', 'struts 2 authoritative Guide ', 60 61 'Li gang', 'electronics Industry Publishing House ', '2017-9-00', 2007, 62 63 'computer class', 715 ); 64 65 insert into book values ('20140901', 'javascript authoritative Guide', 66 67' (US) David Flanagan ', 'machine Industry Publishing House', '2017-8-00 ', 954, 68 69 'computer class', 109.00); 70 71 insert into book values ('20140901', 'spring 9787121042621 core technology and best practices ', 72 73 'liao Xuefeng ', 'electronics Industry Publishing House ', '1970-06-00', 2007, 74 75 'computer class', 509); 76 77 insert into book values ('20140901 ', 'java and mode', 78 79 'hong', 80 81 'electronics Industry Press ', '2017-10-00', 2002, 82 83 'computer class', 1024 ); 84 85 insert into book values ('20140901', 'vb 9787302167792 &. NET 3.0 advanced programming ', 86 87' (US) Bill Evjen; Billy holis; Bill Sheldon ', 88 89 'tsinghua University Press', '2017-2-00 ', 2008, 90 91 'computer class', 45.00); 92 93 insert into book values ('000000', 'javascript advanced programming Design', 94 95' Nicolas C. zakas ', 96 97 'people's post and telecommunications Publishing House', '2017-11-00', 2006, 98 99 'computer class', 532 );

 

2. Enter the MySQL Command Line

Method 1: If the database is not connected, enter mysql-h localhost-u root-p 123456 <d: \ book. SQL and press Enter;

Method 2: When the database has been connected, the command prompt is mysql>, enter source d: \ book. SQL or \. d: \ book. SQL and press Enter.

3. The running results of mysql> \. d: \ book. SQL are as follows:

The above is the script execution process under the MySQL command line. If you want to learn more about the MySQL database, you may wish to take a look at the article: zhangxichao!

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.