In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This paper gives an example to describe the basic sql statements of Mysql database. Share with you for your reference, the details are as follows:
SQL basic statement
1. Login, exit and shortcut keys:
(1) Shortcut keys
-quickly get back to the beginning of the line.
Ctrl + a
-go back to the end of the line
Ctrl + e
-clear the screen
Ctrl + l
-the end.
Ctrl + c + spaces
(2) connect to the database:
-display password
Mysql-uroot-pmysql
-do not display password
Mysql-uroot-p enter password
(3) exit the database:
Quit/exit/ctrl + d
(4) part of the order:
-display the database version
Select version ()
-display time
Select now ()
two。 Database operations:
(1) create:
-create a database
Create database database name charset=utf8
(2) use:
-use the database
Use database name
(3) View:
-View the database currently in use
Select database ()
-View all databases
Show databases
-View create database statements
Show create database database name
(4) Delete:
-Delete the database
Drop database database name
(5) backup and recovery of database (understanding):
-backup
Mysqldump-uroot-p database name > xxx.sql
-recovery
Mysql-uroot-p New Database name < xxx.sql
3. Table structure operation:
(1) View:
-View all tables in the current database
Show tables
-View the table structure
Desc table name
-View table creation statements
Show create table table name
(2) create:
-create a table
Create table table name (field name data type constraint,... .. …… .. ); (auto_increment: automatic growth)
(3) modify:
-add a field
Alter table table name add field name type constraint
-modify fields (do not rename)
Alter table table name modify field name type constraint
-modify the field (rename)
Alter table table name change old field name new field name type constraint
-delete field
Alter table table name drop field name
(4) Delete:
-delete the table:
Drop table table name
4. Table data manipulation:
(1) View:
-View all fields
Select * from table name
-View the specified field
Select field name, field name from table name
-View by condition
Select * from table name where condition
-alias the field to view it.
Select field name as alias from table name
(2) increase:
-insert all columns
Insert into table name values (record)
-partial insertion
Insert into table name (field name) values (record)
-Multi-line insertion
Insert into table name values (record 1), (record 2)...
(3) Delete:
-physical deletion
Delete from table name where condition
-logical deletion
Alter table table name add delete information field name bit dafault 0; update table name set delete information field name = 1 where condition
(4) to modify:
-modify all
Update table name set modification information
-modify according to conditions
Update table name set modification information where condition
More readers who are interested in MySQL-related content can check out this site topic: "MySQL query skills Collection", "MySQL Common function Summary", "MySQL Log Operation skills Collection", "MySQL transaction Operation skills Summary", "MySQL stored procedure skills Collection" and "MySQL Database Lock related skills Summary"
It is hoped that what is described in this article will be helpful to everyone's MySQL database design.
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.