Mysql getting started (3)

xiaoxiao2021-03-06  76

Mysql getting started (3) learning articles (join time: 2002-3-25 Hits: 3888)

ABCCS

After learning some of the most basic operational commands, let's learn how to create a database and database table. 1. Use the show statement to find out what database currently exists on the server: mysql> show databases; -------- | Database | ---------- | MySQL | | TEST | ---------- 3 ROWS IN Set (0.00 sec) 2, create a database Abccs mysql> Create Database Abccs; pay attention to sensitive to case different operating systems. 3, choose the database you created Mysql> Use Abccs database change At this point you have already entered the database ABCCS. 4. Create a database table first look at what tables in your database: mysql> show tables; empty SET (0.00 sec) shows that there is no database table in the database that has just been established. Let's create a database table MyTable: We want to build a birthday table of your company employee, the contents of the table contain employee name, gender, date of birth, birth city. MySQL> Create Table MyTable (Name Varchar (20), Sex Char (1), -> Birth Date, Birthaddr Varchar (20)); Query OK, 0 ROWS Affected (0.00 sec) Due to Name, Birthadd's column value varies Therefore, select varchar, which is not necessarily 20. You can choose any length from 1 to 255, if you need to change its word length, you can use the ALTER TABLE statement. ); Gender only one character can be represented: "m" or "f", so use char (1); Birth column uses the DATE data type.

转载请注明原文地址:https://www.9cbs.com/read-121257.html

New Post(0)