Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql's watch.

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Talking about building a database, there is a database! Here should be the watch. I believe everyone has used excel, which is full of forms, which is just like that. How do we use sql to implement it?

Using USE to use a database is somewhat similar to cd, which can be understood as entering the database.

USE `mysql`

View all tables under the mysql library

SHOW TABLES

View the table structure of a specific table

DESCRIBE `user`

View the creation statement of an existing table

SHOW CREATE TABLE `mysql`.`user`\ G

If you USE the mysql library, you can ignore the library name and go straight to the table name.

SHOW CREATE TABLE `user`\ G

From the user table, we can extract part of it to create a table.

CREATE TABLE `email`python`.`user` (`email`char (100) CHARSET latin1 NOT NULL DEFAULT'', `name` varchar (20) COLLATE utf8_bin NOT NULL DEFAULT'', `gender`boolean, PRIMARY KEY (`email`))

Note:

1. When specifying a table name, specify which database it belongs to, and use. This symbol separates the database name from the table name. However, we can't put. Enclosed in backquotation marks.

two。 Each column is contained in curly braces, and each column is usually written on a line and split with.

3. Tables and columns are the same as databases, and you can set coded character sets and collations separately.

4. If not specified, there is a set of inheritance rules: row-> table-> database-> configuration.

In MySQL, each column must have a specified type, immutable. Types of commonly used columns:

1.char (n): fixed length string

2.varchar (n): a variable length string that defines the maximum length

3.int: integer

4.decimal: fixed point number

5.float: floating point number

6.text: long text

7.blob: bulk binary

8.datatime: date time

9.boolean: Boolean valu

Change the name of the table

RENAME TABLE `user`TO `people`

Move the table

RENAME TABLE `test_ python`.`people`TO `test_ db1`.`users`

Delete tabl

DROP TABLE `users`

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report