MySQL database to create a database

MYSQL build database

1. Open MYSQL5.6Command LineClient-Unicode, enter the MYSQL database password, press [enter key];
Insert picture description here
2… Enter [show databases;] ​​to select to view all the databases in the server in the current database;
Insert picture description here
3. Enter use stu_cour;
Insert picture description here
4. Create a A database to store student course information; enter [stu_cour: creat database stu_cour;]
Insert picture description here
5. Next, start building the table. Before building the table, make sure that we are building the table in the stu_cour database, so we must first enter this database: use stu_cour; You can look at the tables in the current database show tables;
Insert picture description here
6. Start building tables, format: create table table name (column attributes);

CREATE TABLE Student
(Sno CHAR (9) PRIMARY KEY, / column-level integrity constraints, Sno is the main code /
Sname CHAR (20) UNIQUE, / Sname takes a unique value /
Ssex CHAR (2),
Sage SMALLINT,
Sdept CHAR ( 20)
);
7. Insert picture description hereThis completes the establishment of the database table, you can start a variety of operations to add, delete, modify and check!

8. Operation summary
When I learned how to build a MYSQL data table this time, because I have not been exposed to it before and I am unfamiliar with the code, many errors have occurred in the process, but in the continuous attempt to understand and use some statements are more familiar Too. When writing code, it is necessary to write some semicolons and uppercase and lowercase norms, otherwise it will be rewritten because of a symbol, and there are words in some sentences to be remembered, otherwise it will be changed again because of a letter.

Published 9 original articles · Likes0 · Visits 925

Guess you like

Origin blog.csdn.net/weixin_46146588/article/details/105328207