Notes MySQL instance: Build a table and insert data 2

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 (' ' ', ' Glchengang ', ' Shenzhen One ', ' 1976-10-10 ');
INSERT into teacher values (' ' ', ' Jack ', ' Shenzhen One ', ' 1975-12-23 ');

Note that in the table under construction:

      • Set the ID to a number field of length 3: Int (3), and let it automatically add one to each record: auto_increment, and cannot be empty: NOT NULL, and let him be the main field primary key.
      • Set name to a character field of length 10
      • The address is set to a character field of length 50, and the default value is Shenzhen.
      • Set year as the Date field.

Notes MySQL instance: Build a table and insert data 2

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.