In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article is to share with you about how to use SQL statements. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
How to use SQL statement
1. Database operation: database
Create a database
Syntax:
* createdatabase database name
* createdatabase database name characterset character set
View the database
View all the databases in the database server: showdatabase
View information about a database definition: showcreatedatabase database name
Delete database
Dropdatabase database name
Other database operation commands
Toggle database: use database name
View the database in use: selectdatabase ()
Table operation: table
Field Type
The commonly used types are:
Digital: int
Floating point: double
Character type: varchar (variable length string)
Date type: date (only year, month, day, no hour, minute and second)
Datetime (year, month, day, hour and second)
Boolean type: not supported
Create a tabl
Createtable table name (
Field name type (length) constraint
Field name type (length) constraint
)
View tabl
View all tables in the database: showtables
View table structure: desc table name
Delete tabl
Droptable table name
Modify the table
Altertable table name add column name type (length) constraint;-- modify the table to add columns.
Altertable table name modify column name type (length) constraint;-modify table modify column type length and constraints.
Altertable table name change old column name new column name type (length) constraint;-- modify table modify column name.
Altertable table name drop column name;-- modify table to delete column
Renametable table name to new table name;-- modify table name
Altertable table name characterset character set;-- modify the character set of the table
Insert record
Syntax:
Insertinto table (column name 1, column name 2, column name 3.) values (value 1, value 2, value 3.);-- insert some columns into the table
Insertinto table values (value 1, value 2, value 3.);-- insert all columns into the table
Insertinto table (column name 1, column name 2, column name 3.) valuesselect (column name 1, column 2, column name 3) from table
Insertinto table valuesselect*from table
Thank you for reading! This is the end of this article on "how to use SQL sentences". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.