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--
Mysql creates tables from the command line
1. Syntax:
CREATE TABLE IF NOT EXISTS table name (
Field 1 [AS alias] Field Type [constraint] [DEFAULT default] [COMMENT comment]
Field 2 [AS alias] Field Type [constraint] [DEFAULT default] [COMMENT comment]
.
) ENGINE = Table Storage engine DEFAULT CHARSET = default Encoding set AUTO_INCREMENT = starting value from increasing primary key
two。 Syntax parsing:
CREATE TABLE: create table command
IF NOT EXISTS: determines whether the table exists, creates the table if it does not exist, and does not create it if it exists
Table name: name according to business needs
Field 1: the name of the field in this table, which can have multiple fields
[AS alias]: you can have an alias for each field
Field types: data typ
[constraints]: constraints on the current field
[DEFAULT default]: the default value used when this field is not assigned
[COMMENT Note]: optional, but very necessary in practical work, which directly reflects the original intention of the design of this field.
Table storage engines: MyISAM and InnoDB
Default code set: same as the database code
Starting value of self-increasing primary key: can be modified. Default starts from 1.
3. Example:
# create a table
CREATE TABLE IF NOT EXISTS student (
Sid INT (4) unsigned NOT NULL AUTO_INCREMENT COMMENT 'SID'
Name VARCHAR (30) NOT NULL COMMENT 'name'
Sex TINYINT (2) unsigned NOT NULL DEFAULT 1 COMMENT 'Sex 1 male 0 female'
PRIMARY KEY (sid)
) ENGINE = MyISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT = 1
4. Screenshot of the running result:
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.