MySQL Build database Build table

Source: Internet
Author: User

Always use a SQL SERVER database; The most recent project using my SQL feels a bit out of the way. But it's a lot better when you're familiar.

After MY SQL installation there will be a management tool MySQL Workbench feel not very good, database backup import always have some strange problems, later from the download SQLyog feel more cool.

The following separately describes the use of the SQLYOG management tool and SQL statements to build a database table.

I. Using SQLYOG to build a table

In fact, using the SQLyog tool to build the database and SQL Server is not the difference between the visualization, just click the corresponding button, fill in the content;

The steps are as follows:

1. After starting SQLyog, click File-New connection; connect MySQL server

2. Select Server Right-click Create Database

3, select the corresponding library click Create TABLE

4, fill in the corresponding field information can be

5. Close and save after completion

At this end a simple database has been built.

II. using SQL statements to build a database table

1. Creating a Database

CREATE DATABASE Test

2. Create a user-type data table

CREATE TABLE ' usertype ' (

' ID ' INT (one) not NULL auto_increment,

' TypeName ' VARCHAR ($) DEFAULT NULL COMMENT ' user type name ',

' Typedescript ' VARCHAR ($) DEFAULT NULL COMMENT ' user type description ',

PRIMARY KEY (' ID ')

)

3. Create a user information data sheet

CREATE TABLE ' UserInfo ' (

' ID ' INT (one) not NULL auto_increment COMMENT ' self-increment primary key ',

' UserName ' VARCHAR ($) DEFAULT NULL COMMENT ' user name ',

' Userlogin ' VARCHAR ($) DEFAULT NULL COMMENT ' user login name ',

' UserPassword ' VARCHAR ($) DEFAULT NULL COMMENT ' password ',

' UserEmail ' VARCHAR (+) DEFAULT NULL COMMENT ' e-mail ',

' Usertype ' INT (one) DEFAULT NULL COMMENT ' user type ',

PRIMARY KEY (' ID '),

KEY ' usertype ' (' usertype '),

CONSTRAINT ' Userinfo_ibfk_1 ' FOREIGN KEY (' usertype ') REFERENCES ' usertype ' (' ID ')

)

MySQL Build database Build table

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.