Notes MySQL instance: Build a table and insert data 1

Source: Internet
Author: User

drop database if exists school; Delete if school is present
CREATE DATABASE School; Building a library school
Use School; Open Library School
CREATE TABLE Teacher (//Build tables Teacher
ID int (3) auto_increment NOT NULL primary key,
name Char (TEN) is not NULL,
address varchar (+) Default ' Shenzhen ',
Year date
); End of Build table

//Below is the Insert field
INSERT INTO teacher values (", ' Allen ', ' Dalian One ', ' 1976-10-10′ ');
INSERT INTO teacher values (", ' Jack ', ' Dalian II ', ' 1975-12-23′ ');

It is also possible to type the above commands at the MySQL prompt, but it is not easy to debug. There are two ways to solve this problem:

      • You can write the above command as-is to a text file, assume that it is school.sql, then copy it to c:\\, and enter the directory in the DOS state [Url=file://\\mysql\\bin]\\mysql\\bin[/url], and then type the following command:
        Mysql-uroot-p Password < C:\\school.sql
        If successful, empty a row without any display, and if there is an error, there is a hint. (The above command has been debugged, you can use it only if you remove//comment).
      • Alternatively, use mysql> source c:\\school.sql after entering the command line; You can also import the School.sql file into the database.

Notes MySQL instance: Build a table and insert data 1

Related Article

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.