Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction to the basic SQL statement of MYSQL

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The following is mainly to bring you MYSQL basic SQL statement introduction, I hope these contents can bring you practical use, this is also the main purpose of my editing MYSQL basic SQL statement introduction this article. Okay, no more nonsense, let's go straight to the following.

MySQL is a relational database management system that stores data in different tables rather than putting all the data in one large warehouse, which increases speed and flexibility. Because MYSQL is an open source software, it can significantly reduce total cost of ownership. Now let's introduce MYSQL's original SQL statement, set up MYSQL account locally, create my.ini file

[mysqld]

character-set-server=utf8 #The encoding mode of the library is set to utf8

collation-server=utf8_general_ci

[client]

default-character-set=utf8

user=root #Account name is root

[mysql]

default-character-set=utf8 #For every library created, the default encoding is utf8

MYSQL installation will be added to the target file environment variables, in CMD direct operation MYSQL database. Open MYSQL without entering the account password, default from the configuration file my.ini read mode set to strict mode set global sql_mode= "strict_trans_tables,only_full_group_by"; #Modify to strict mode, can only view the grouped fields, with aggregation function. For example:select * from emo group by post; #will report error, because it is meaningless to view a certain piece of data after grouping. Emphasis: mode is set to strict mode. MYSQL needs to be restarted. MYSQL is set to run automatically in the background.

MYSQL original SQL statement library: essentially a folder increase

create database folder name charset utf8; delete

drop database folder name; modify

alter database folder name charset gbk; #modify refers to modifying the encoding of a folder View

show databases; #View all folders

show create database folder name; #view specified folder table: that is, a file switch library: use library name emphasis: all file creation operations or file content operations premise is in this library, or add prefix, library name increase

ceate table table name (id int primary key auto_increase, #indicates that ID is not empty and the only one will automatically increase

name varchar(16) not null #Not null) Delete

drop table file name modification

alter table filename add age int; #add: add an attribute

alter table filename modify nae char(30); #modify: cannot change the header, the rest can be changed

alter table filename change NAME char(15); #change: both header and attribute can be changed

alter table filename drop age; #drop: remove age this header View

show tables; #View all tables in the current library

show create table filename; #View only that one specified table

desc filename; #View all properties in the specified table View current library

select database(); record: that is, the contents of a line

:: Increase

insert into filename (id,name) values

(1,'egon'),

(2,'lxx'),

(3,'alex');

delete

delete from library name. file name where id>=2; #output specific line according to pick

Empty the table should use:

truncate file name modification

Update library name. file name set name='lxx_dsb' where id=2; #Update the table under the specified folder, by conditional judgment, set name= what View

select id from library name. File name; #View library name. All ids under file name

select id,name from filename; #View all id, name under filename

select name,id from filename; #View all names,id under filename

select from file name; #View everything under file name

select from filename where id>=2; #View only everything under filename id>=2

For the above basic SQL statements about MYSQL, do you think it is very helpful? If you need to know more, please continue to pay attention to our industry information, I believe you will like these contents.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report