当前位置:网站首页>MySQL syntax (basic)
MySQL syntax (basic)
2022-07-03 06:58:00 【ZzzzzzOOOOO】
MySQL grammar
Download and install MySQL
Log in to the database
mysql -uroot -p # Use root The user login mysql The server
Display all databases
show databases;
Using a database
use Database name ;
Query all data tables in the database
show tables;
View the column information in the data table
desc Data sheet ;mysql> desc person; +-------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+----------------+ | id | int | NO | PRI | NULL | auto_increment | | name | varchar(10) | NO | | NULL | | +-------+-------------+------+-----+---------+----------------+- Create database
create database Database name ;
Delete database
drop database Database name ;Create data table
create table Data table name ( Field name , Field type );# auto_increment Defined as self increasing , Generally used for primary key , The value will automatically +1 # primary key Used to define the primary key # default charset Set the encoding format create table test(id int(10) not null auto_increment, name varchar(10) not null, age int(10) not null, primary key(id)) default charset=utf8;Delete data table
drop table Data table name ;insert data
insert into Data table name (key1, key2, key3...) values (value1, value2, value3...);insert into test(name, age) values (" Zhang San ", 18);Query data
select * from Data table name ; # Query all contents in the data table
select Column from database where Conditions limit N; # Query the contents of the specified conditions in the data table ( front N Data )# Inquire about test Everything in select * from test; # Inquire about test in id=1 Of name select name from test where id=1; # Inquire about test in age=33 Before 4 individual name select name from test where age=33 limit 4;Update data
update Data table name set column1=value1, column2=value2..where Conditions ;# to update test In the table id=1 when ,name and age Value update test set name=" Li Si ", age=28 where id=1;Delete data
delete from Data table name where Conditions ;# Delete test Everything in the table ,test The watch still exists , Content delete delete from test; # Delete test In the table name=" Li Si " The line of delete from test where name=" Li Si "like usage
select column from Data sheet where column like "%";# Inquire about test In the table x At the beginning name select name from test where name like "x%"; # Inquire about test In the table d At the end of the name select name from test where name like "%d";union usage
Connect more than two select The results of a statement are combined into a set of results
select column from table1 union select column from table2;# from person Table and test Table acquisition name Set ( Delete duplicate data ) select name from person union select name from test; # from person Table and test Table acquisition name Set ( Contains duplicate data ) select name from person union all select name from test;- alter usage
add to 、 Delete 、 Modify the columns of the table / constraint# Modify the name of the table alter table person rename to t_person; # add to age Column alter table person add age int(10); # Delete age Column alter table person drop age; # modify age Change the name to column_age alter table person change age column_age int(10); # modify age Column properties alter table person modify age int(20);
边栏推荐
- Pits encountered in the use of El checkbox group
- Error c2017: illegal escape sequence
- Practice of enterprise ab/testing platform
- What are the characteristics and functions of the scientific thinking mode of mechanical view and system view
- 【类和对象】深入浅出类和对象
- JMeter JSON extractor extracts two parameters at the same time
- [Fiddler actual operation] how to use Fiddler to capture packets on Apple Mobile Phones
- POI excel percentage
- EasyExcel
- Application scenarios of Catalan number
猜你喜欢

Machine learning | simple but feature standardization methods that can improve the effect of the model (comparison and analysis of robustscaler, minmaxscaler, standardscaler)
![[open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle](/img/f8/0e3fbfd13bf06291a73200552ff17a.png)
[open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle

Golang operation redis: write and read kV data

Integration test practice (1) theoretical basis

DBNet:具有可微分二值化的实时场景文本检测

POI excel percentage

How to migrate or replicate VMware virtual machine systems

JMeter JSON extractor extracts two parameters at the same time

2022 - 06 - 23 vgmp - OSPF - Inter - Domain Security Policy - nat Policy (Update)

On the practice of performance optimization and stability guarantee
随机推荐
Practical plug-ins in idea
Sorting out the core ideas of the pyramid principle
Pits encountered in the use of El checkbox group
这两种驱蚊成份对宝宝有害,有宝宝的家庭,选购驱蚊产品要注意
Class and object summary
Golang operation redis: write and read kV data
Jenkins
2022 cisp-pte (III) command execution
Journal quotidien des questions (11)
What are the characteristics and functions of the scientific thinking mode of mechanical view and system view
centos php7.3安装redis扩展
La loi des 10 000 heures ne fait pas de vous un maître de programmation, mais au moins un bon point de départ
Reading notes of "learn to ask questions"
IC_EDA_ALL虚拟机(丰富版):questasim、vivado、vcs、verdi、dc、pt、spyglass、icc2、synplify、INCISIVE、IC617、MMSIM、工艺库
The list of "I'm crazy about open source" was released in the first week, with 160 developers on the list
JMeter JSON extractor extracts two parameters at the same time
New knowledge! The virtual machine network card causes your DNS resolution to slow down
Operation principle of lua on C: Foundation
[untitled]
SQL implementation merges multiple rows of records into one row