当前位置:网站首页>Basic usage of MySQL
Basic usage of MySQL
2022-06-11 06:01:00 【Not bald】
Mysql Basic use
Basic knowledge of database
The database is based on the hard disk to persist the data it needs , The database management mode not only improves the data storage efficiency , And it improves the security of data at the storage level .
Mseql Basic data types and related statements
value type : int,bigint,tinint,mediumint
String type : char,varchar
The date type : datatime,data
DQL( Data query language ):select sentence
DML( Data operation language ): Add, delete and modify the data in the table insert,delete,update
wait .
view the database :show databases;
Using a database : use Database name ;
View database tables :show tables;
View table structure : desc Table name ;
Delete Library :drop database Database name ;
Use JDBC
Recently, I have been learning about the basic use of databases and related concepts , Including the use of idea And JDBC Connect to the database , And use idea Add, delete, modify and query the contents of the database .
Use JDBC The first step is to download jar package , Then introduce the jar The step of packaging into the project is crucial , Then there are six key steps
1. Registration drive
2. Get database connection
3. Get database operation object
4. perform SQL sentence
5. Process query results
6. Release resources
The following code takes a query as an example
import com.mysql.jdbc.Driver;
import java.sql.*;
public class jdbc {
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
DriverManager.registerDriver(new Driver());
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/bjpowernode", "root", "root");
stmt = conn.createStatement();
String sql = "select e.ename,d.dname from emp e join dept d on e.deptno = d.deptno0";
rs = stmt.executeQuery(sql);
while (rs.next()) {
String ename = rs.getNString("ename");
String dname = rs.getNString("dname");
System.out.println(ename + "," + dname);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
}
}
}
summary
After this period of study , I realized the difficulty of the back end , Learning is very miscellaneous , It's hard to understand , But there is no other way , Only hand ripe , come on. !
边栏推荐
- Which company is better in JIRA organizational structure management?
- The meaning in the status column displayed by PS aux command
- YOLOv5的Tricks | 【Trick8】图片采样策略——按数据集各类别权重采样
- Delegation agreement, data source agreement and advanced view in view
- Invert an array with for
- Sqli-libs post injection question 11-17 actual combat
- All the benefits of ci/cd, but greener
- [metadata]linkedin datahub
- Activity start process record
- Sword finger offer 32: print binary tree from top to bottom
猜你喜欢

Sqli-libs range 23-24 filtration and secondary injection practice
![Experimental report on information management and information system [information security and confidentiality] of Huazhong Agricultural University](/img/f6/e58196aeac85178f6603cea1962a6e.jpg)
Experimental report on information management and information system [information security and confidentiality] of Huazhong Agricultural University

Yonghong Bi product experience (I) data source module

This is probably the most comprehensive project about Twitter information crawler search on the Chinese Internet

Use com youth. banner. Solution to the inflateexception reported by the banner plug-in

AltiumDesigner2020导入3D Body-SOLIDWORKS三维模型

Cenos7 builds redis-3.2.9 and integrates jedis

NDK learning notes (VIII) thread related

Control your phone with genymotion scratch
![Yoyov5's tricks | [trick8] image sampling strategy -- Sampling by the weight of each category of the dataset](/img/54/f6a3e0ef1f77901506642784e6d3b7.png)
Yoyov5's tricks | [trick8] image sampling strategy -- Sampling by the weight of each category of the dataset
随机推荐
Delegation agreement, data source agreement and advanced view in view
NDK learning notes (12) native graphics API, using avilib to create an avi video player
Installing and using sublist3r in Kali
More than 20 cloud collaboration functions, 3 minutes to talk through the enterprise's data security experience
NLP-D46-nlp比赛D15
NFC Development -- the method of using NFC mobile phones as access control cards (II)
Clear function of ArrayList
What is a thread pool?
Twitter data collection (content, fans, keywords, etc.)
Installing MySQL for Linux
ThymeleafEngine模板引擎
20多种云协作功能,3分钟聊透企业的数据安全经
[daily exercises] merge two ordered arrays
Utiliser le fichier Batch Enum
Dism command usage summary
NDK R21 compiles ffmpeg 4.2.2 (x86, x86_64, armv7, armv8)
Informatica: six steps of data quality management
NDK learning notes (VII) system configuration, users and groups
NDK learning notes (V)
NDK learning notes (IX) POSIX sockect connection oriented communication