当前位置:网站首页>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. !
边栏推荐
- Sqli-libs post injection question 11-17 actual combat
- Observer mode (listener mode) + thread pool to realize asynchronous message sending
- Yonghong Bi product experience (I) data source module
- MySQL implements over partition by (sorting the data in the group after grouping)
- What should the cross-border e-commerce evaluation team do?
- Can Amazon, express, lazada and shrimp skin platforms use the 911+vm environment to carry out production number, maintenance number, supplement order and other operations?
- Activity start process record
- Warmly celebrate that yeyanxiu, senior consultant of Longzhi, won the title of "atlassian Certified Expert"
- JS -- reference type
- NFC Development -- the method of using NFC mobile phones as access control cards (II)
猜你喜欢

Warmly celebrate that yeyanxiu, senior consultant of Longzhi, won the title of "atlassian Certified Expert"

Error:Execution failed for task ':app:buildNative'. & gt; A problem occurred'x/x/x/'NDK build' error resolution

All questions and answers of database SQL practice niuke.com

View controller and navigation mode
![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
![[must see for game development] 3-step configuration p4ignore + wonderful Q & A analysis (reprinted from user articles)](/img/4c/42933ac0fde18798ed74a23279c826.jpg)
[must see for game development] 3-step configuration p4ignore + wonderful Q & A analysis (reprinted from user articles)

NDK R21 compiles ffmpeg 4.2.2 (x86, x86_64, armv7, armv8)

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

Sqli-libs post injection question 11-17 actual combat

ThymeleafEngine模板引擎
随机推荐
What should the cross-border e-commerce evaluation team do?
Yonghong Bi product experience (I) data source module
Fix [no Internet, security] problem
“All in ONE”一个平台解决所有需求,运维监控3.0时代已来
NDK learning notes (12) native graphics API, using avilib to create an avi video player
Do you know the functions of getbit and setbit in redis?
URL in flask_ for
Observer mode (listener mode) + thread pool to realize asynchronous message sending
What happened to the young man who loved to write code -- approaching the "Yao Guang young man" of Huawei cloud
Set the IP address using batch
Share an RSA encryption and decryption tool class, including public key encryption, private key decryption, private key encryption, public key decryption, private key signature, public key verificatio
Principle of copyonwritearraylist copy on write
How to deal with message blackout and message sending failure of Aurora im
Control your phone with genymotion scratch
DISM命令使用小结
使用Batch枚舉文件
AltiumDesigner2020导入3D Body-SOLIDWORKS三维模型
ELK日志系统实战(五):安装vector并将数据输出到es、clickhouse案例
Xposed bypasses 360 reinforcement to get a real classloader
[metadata]linkedin datahub