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)05/31 Report--
This article is about basic database operations. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.
What are the basic database operations?
Basic database operations include:
1 Basic operations on databases
SHOW DATABASES;//Query database SHOW CREATE DATABASE score; //Query database structure CREATE DATABASE score DEFAULT CHARSET utf8; //Create database USE score; //Use score database DROP DATABASE score; //Delete database
2 Operations on tables
SHOW TABLES; //Display tables in the database CREATE TABLE score(sno INT PRIMARY KEY AUTO_INCREMENT,course VARCHAR(20),sscore SMALLINT); //Create table SHOW CREATE TABLE score; //Display the construct table statement DESC score; //Display table knot ALTER TABLE scoreADD startTime DATE NOT NULL; //add field ALTER TABLE scoreDROP startTime; //delete fields ALTER TABLE scoreMODIFY course VARCHAR(50); //modify field type ALTER TABLE scoreCHANGE startTime endTime DATE; //Change field name DROP TABLE score; //Delete table
3 Management data
INSERT INTO score(course,sscore)VALUES ('language ', 80); //add data UPDATE scoreSET sscore=90WHERE sno=1; //Delete from scoreWHERE sno=1; //Delete data
4 Inquiry data
SELECT * FROM score; //Query all field data
Select distinct field from table name where condition
Logical conditions: and or
Comparison conditions:
< , , >=, , between value1 and value2
Judgment null:
1) null: is null
2)Judge empty string: ="" / ""
Fuzzy condition: like
%: Replace arbitrary length characters
_: Replace a single character
pagination query, limit start row, query rows
Sort: order by field asc/desc
asc: ascending
desc: descending order
Group: group by field
5 Code queries in databases
SHOW VARIABLES LIKE 'character%';Variable_name Valuecharacter_set_client utf8character_set_connection utf8character_set_database utf8character_set_filesystem binarycharacter_set_results utf8character_set_server utf8character_set_system utf8character_sets_dir C:\\Program Files\\MySQL\\MySQL Server 5.7\\share\\charsets\\
If garbled characters appear in the query process, they can be solved by setting the corresponding character encoding.
For example, when cmd client queries, there may be Chinese in the database, the code set by database character_set_client is utf8, and cmd interpretation is interpreted by gbk. So there will be garbled code, set the character_set_client code to gbk.
SET character_set_client='gbk'; Thank you for reading! About "database basic operation statement" this article is shared here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!
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.