In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article is to share with you about how to create mysql database data tables, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article. Let's take a look at it with the editor.
The mysql database can create data tables through CREATE TABLE statements. The basic syntax is: [CREATE TABLE ([table definition options]) [table options] [partition options];]. It is important to note that you cannot use keywords in the SQL language to create data tables.
In MySQL, you can use CREATE TABLE statements to create tables. Its grammatical format is:
CREATE TABLE ([Table definition options]) [Table options] [Partition options]
The format of "Table definition options" is:
[,...]
There are many syntax for CREATE TABLE command, which is mainly composed of table creation definition (create-definition), table option (table-options), and partitioning option (partition-options).
The main syntax and usage instructions of the CREATE TABLE statement are as follows:
CREATE TABLE: used to create a table with a given name, you must have permission for the table CREATE.
Specifies the name of the table to be created, given after CREATE TABLE, and must conform to the naming convention for identifiers The table name is specified as db_name.tbl_name to create the table in a specific database. It can be created in this way, regardless of whether there is a current database or not.
You can omit db-name when you create a table in the current database. If you use a quoted distinguished name, the database and table names should be in quotation marks, respectively. For example, 'mydb'.'mytbl' is legal, but' mydb.mytbl' is illegal.
A table creation definition consisting of a column name (col_name), a column definition (column_definition), and a possible null value description, integrity constraint, or table index By default, the table is created into the current database. An error occurs if the table already exists, there is no current database, or the database does not exist.
Tip: when you create a table using CREATE TABLE, you must specify the following information:
The name of the table to be created is case-insensitive and cannot use keywords in the SQL language, such as DROP, ALTER, INSERT, and so on.
The name and data type of each column (field) in the data table. If you create multiple columns, separate them with commas.
Example:
For example, create the employee table tb_emp1, with the structure shown in the following table.
Select the database test_db that created the table, and create the tb_emp1 data table. Enter the SQL statement and run the results as shown below.
Mysql > USE test_db;Database changedmysql > CREATE TABLE tb_emp1-> (- > id INT (11),-> name VARCHAR (25),-> deptId INT (11),-> salary FLOAT->); Query OK, 0 rows affected (0.37 sec)
After the statement is executed, a data table named tb_emp1 is created, and the SHOW TABLES; statement is used to see if the data table is created successfully, as shown below.
Mysql > SHOW TABLES +-+ | Tables_in_test_db | +-+ | tb_emp1 | +-+ 1 rows in set (0.00 sec) above is how to create mysql database tables The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.