Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

feat: add Oracle database support

t8y22e971ce1525c
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index cd88a6ad9d..bc3964a8e1 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -8,6 +8,17 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
+[[package]]
+name = "aes"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
+dependencies = [
+ "cfg-if",
+ "cipher",
+ "cpufeatures",
+]
+
[[package]]
name = "ahash"
version = "0.7.8"
@@ -353,6 +364,28 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
+[[package]]
+name = "aws-lc-rs"
+version = "1.16.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ec6fb3fe69024a75fa7e1bfb48aa6cf59706a101658ea01bfd33b2b248a038f"
+dependencies = [
+ "aws-lc-sys",
+ "zeroize",
+]
+
+[[package]]
+name = "aws-lc-sys"
+version = "0.40.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f50037ee5e1e41e7b8f9d161680a725bd1626cb6f8c7e901f91f942850852fe7"
+dependencies = [
+ "cc",
+ "cmake",
+ "dunce",
+ "fs_extra",
+]
+
[[package]]
name = "base64"
version = "0.21.7"
@@ -422,6 +455,15 @@ dependencies = [
"generic-array",
]
+[[package]]
+name = "block-padding"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93"
+dependencies = [
+ "generic-array",
+]
+
[[package]]
name = "block2"
version = "0.6.2"
@@ -633,6 +675,15 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
+[[package]]
+name = "cbc"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"
+dependencies = [
+ "cipher",
+]
+
[[package]]
name = "cc"
version = "1.2.61"
@@ -698,6 +749,25 @@ dependencies = [
"windows-link 0.2.1",
]
+[[package]]
+name = "cipher"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
+dependencies = [
+ "crypto-common",
+ "inout",
+]
+
+[[package]]
+name = "cmake"
+version = "0.1.58"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678"
+dependencies = [
+ "cc",
+]
+
[[package]]
name = "combine"
version = "4.6.7"
@@ -1048,6 +1118,7 @@ dependencies = [
"duckdb",
"log",
"mongodb",
+ "oracle-rs",
"portpicker",
"redis",
"reqwest 0.12.28",
@@ -1593,6 +1664,12 @@ dependencies = [
"percent-encoding",
]
+[[package]]
+name = "fs_extra"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
+
[[package]]
name = "funty"
version = "2.0.0"
@@ -2172,6 +2249,17 @@ dependencies = [
"windows-sys 0.61.2",
]
+[[package]]
+name = "hostname"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "617aaa3557aef3810a6369d0a99fac8a080891b68bd9f9812a1eeda0c0730cbd"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "windows-link 0.2.1",
+]
+
[[package]]
name = "html5ever"
version = "0.29.1"
@@ -2267,7 +2355,7 @@ dependencies = [
"tokio",
"tokio-rustls",
"tower-service",
- "webpki-roots",
+ "webpki-roots 1.0.7",
]
[[package]]
@@ -2492,6 +2580,16 @@ dependencies = [
"cfb",
]
+[[package]]
+name = "inout"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
+dependencies = [
+ "block-padding",
+ "generic-array",
+]
+
[[package]]
name = "ipconfig"
version = "0.3.4"
@@ -3112,7 +3210,7 @@ dependencies = [
"tokio-util",
"typed-builder",
"uuid",
- "webpki-roots",
+ "webpki-roots 1.0.7",
]
[[package]]
@@ -3505,6 +3603,39 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
+[[package]]
+name = "oracle-rs"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c9ca364b441f92b717658c62e85207158b30285deb01811ccd923017f61612e"
+dependencies = [
+ "aes",
+ "async-trait",
+ "bytes",
+ "cbc",
+ "chrono",
+ "hex",
+ "hmac",
+ "hostname",
+ "indexmap 2.14.0",
+ "md-5",
+ "pbkdf2",
+ "pkcs8",
+ "rand 0.8.6",
+ "rustls",
+ "rustls-pemfile",
+ "rustls-pki-types",
+ "serde",
+ "serde_json",
+ "sha1",
+ "sha2",
+ "thiserror 1.0.69",
+ "tokio",
+ "tokio-rustls",
+ "tracing",
+ "webpki-roots 0.26.11",
+]
+
[[package]]
name = "os_pipe"
version = "1.2.3"
@@ -3582,6 +3713,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2"
dependencies = [
"digest",
+ "hmac",
]
[[package]]
@@ -3803,6 +3935,21 @@ dependencies = [
"spki",
]
+[[package]]
+name = "pkcs5"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e847e2c91a18bfa887dd028ec33f2fe6f25db77db3619024764914affe8b69a6"
+dependencies = [
+ "aes",
+ "cbc",
+ "der",
+ "pbkdf2",
+ "scrypt",
+ "sha2",
+ "spki",
+]
+
[[package]]
name = "pkcs8"
version = "0.10.2"
@@ -3810,6 +3957,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7"
dependencies = [
"der",
+ "pkcs5",
+ "rand_core 0.6.4",
"spki",
]
@@ -4359,7 +4508,7 @@ dependencies = [
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
- "webpki-roots",
+ "webpki-roots 1.0.7",
]
[[package]]
@@ -4563,6 +4712,7 @@ version = "0.23.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef86cd5876211988985292b91c96a8f2d298df24e75989a43a3c73f2d4d8168b"
dependencies = [
+ "aws-lc-rs",
"log",
"once_cell",
"ring",
@@ -4572,6 +4722,15 @@ dependencies = [
"zeroize",
]
+[[package]]
+name = "rustls-pemfile"
+version = "2.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50"
+dependencies = [
+ "rustls-pki-types",
+]
+
[[package]]
name = "rustls-pki-types"
version = "1.14.1"
@@ -4588,6 +4747,7 @@ version = "0.103.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e"
dependencies = [
+ "aws-lc-rs",
"ring",
"rustls-pki-types",
"untrusted",
@@ -4605,6 +4765,15 @@ version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
+[[package]]
+name = "salsa20"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213"
+dependencies = [
+ "cipher",
+]
+
[[package]]
name = "same-file"
version = "1.0.6"
@@ -4680,6 +4849,17 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+[[package]]
+name = "scrypt"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0516a385866c09368f0b5bcd1caff3366aace790fcd46e2bb032697bb172fd1f"
+dependencies = [
+ "pbkdf2",
+ "salsa20",
+ "sha2",
+]
+
[[package]]
name = "seahash"
version = "4.1.0"
@@ -6853,6 +7033,15 @@ dependencies = [
"system-deps",
]
+[[package]]
+name = "webpki-roots"
+version = "0.26.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9"
+dependencies = [
+ "webpki-roots 1.0.7",
+]
+
[[package]]
name = "webpki-roots"
version = "1.0.7"
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 527f0f4644..db857e4187 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -42,3 +42,4 @@ tiberius = { version = "0.12.3", features = ["tds73", "chrono"] }
tokio-util = { version = "0.7", features = ["compat"] }
reqwest = { version = "0.12", features = ["json"] }
mongodb = "3.2.5"
+oracle-rs = "0.1"
diff --git a/src-tauri/src/commands/connection.rs b/src-tauri/src/commands/connection.rs
index 8ea9ca444a..ac2693afad 100644
--- a/src-tauri/src/commands/connection.rs
+++ b/src-tauri/src/commands/connection.rs
@@ -16,6 +16,7 @@ pub enum PoolKind {
MongoDb(mongodb::Client),
ClickHouse(db::clickhouse_driver::ChClient),
SqlServer(std::sync::Arc<tokio::sync::Mutex<db::sqlserver::SqlServerClient>>),
+ Oracle(std::sync::Arc<tokio::sync::Mutex<db::oracle_driver::OraclePool>>),
}
pub struct AppState {
@@ -38,20 +39,24 @@ impl AppState {
connection_id: &str,
database: Option<&str>,
) -> Result<String, String> {
- let is_embedded = {
+ let db_type = {
let configs = self.configs.lock().await;
- configs.get(connection_id)
- .map(|c| c.db_type == DatabaseType::Sqlite || c.db_type == DatabaseType::DuckDb)
- .unwrap_or(false)
+ configs.get(connection_id).map(|c| c.db_type.clone())
};
+ let is_embedded = matches!(db_type, Some(DatabaseType::Sqlite) | Some(DatabaseType::DuckDb));
if is_embedded {
return Ok(connection_id.to_string());
}
- let pool_key = match database {
- Some(db) => format!("{connection_id}:{db}"),
- None => connection_id.to_string(),
+ let is_single_conn = matches!(db_type, Some(DatabaseType::Oracle));
+ let pool_key = if is_single_conn {
+ connection_id.to_string()
+ } else {
+ match database {
+ Some(db) => format!("{connection_id}:{db}"),
+ None => connection_id.to_string(),
+ }
};
let conns = self.connections.lock().await;
@@ -69,7 +74,9 @@ impl AppState {
let mut db_config = config.clone();
if let Some(db) = database {
- db_config.database = Some(db.to_string());
+ if db_config.db_type != DatabaseType::Oracle {
+ db_config.database = Some(db.to_string());
+ }
}
let url = db_config.connection_url();
@@ -102,6 +109,14 @@ impl AppState {
).await?;
PoolKind::SqlServer(std::sync::Arc::new(tokio::sync::Mutex::new(client)))
}
+ DatabaseType::Oracle => {
+ let pool = db::oracle_driver::OraclePool::connect(
+ &db_config.host, db_config.port,
+ db_config.database.as_deref().unwrap_or("ORCL"),
+ &db_config.username, &db_config.password,
+ ).await?;
+ PoolKind::Oracle(std::sync::Arc::new(tokio::sync::Mutex::new(pool)))
+ }
};
self.connections.lock().await.insert(pool_key.clone(), pool);
@@ -113,9 +128,19 @@ impl AppState {
connection_id: &str,
database: Option<&str>,
) -> Result<String, String> {
- let pool_key = match database {
- Some(db) => format!("{connection_id}:{db}"),
- None => connection_id.to_string(),
+ let is_single_conn = {
+ let configs = self.configs.lock().await;
+ configs.get(connection_id)
+ .map(|c| c.db_type == DatabaseType::Oracle)
+ .unwrap_or(false)
+ };
+ let pool_key = if is_single_conn {
+ connection_id.to_string()
+ } else {
+ match database {
+ Some(db) => format!("{connection_id}:{db}"),
+ None => connection_id.to_string(),
+ }
};
self.connections.lock().await.remove(&pool_key);
self.get_or_create_pool(connection_id, database).await
@@ -196,6 +221,14 @@ pub async fn test_connection(config: ConnectionConfig) -> Result<String, String>
).await?;
Ok("Connection successful".to_string())
}
+ DatabaseType::Oracle => {
+ let _pool = db::oracle_driver::OraclePool::connect(
+ &config.host, config.port,
+ config.database.as_deref().unwrap_or("ORCL"),
+ &config.username, &config.password,
+ ).await?;
+ Ok("Connection successful".to_string())
+ }
}
}
@@ -245,6 +278,14 @@ pub async fn connect_db(
config.database.as_deref(),
).await?;
PoolKind::SqlServer(std::sync::Arc::new(tokio::sync::Mutex::new(client))) }
+ DatabaseType::Oracle => {
+ let pool = db::oracle_driver::OraclePool::connect(
+ &config.host, config.port,
+ config.database.as_deref().unwrap_or("ORCL"),
+ &config.username, &config.password,
+ ).await?;
+ PoolKind::Oracle(std::sync::Arc::new(tokio::sync::Mutex::new(pool)))
+ }
};
state.connections.lock().await.insert(id.clone(), pool);
@@ -275,6 +316,7 @@ pub async fn disconnect_db(
PoolKind::MongoDb(_) => {},
PoolKind::ClickHouse(_) => {},
PoolKind::SqlServer(_) => {},
+ PoolKind::Oracle(_) => {},
}
}
}
diff --git a/src-tauri/src/commands/query.rs b/src-tauri/src/commands/query.rs
index e7f0eb137c..bfa67d5caf 100644
--- a/src-tauri/src/commands/query.rs
+++ b/src-tauri/src/commands/query.rs
@@ -132,6 +132,15 @@ async fn do_execute(
.map_err(|_| format!("Query timed out after {} seconds", QUERY_TIMEOUT.as_secs()))?
.map(truncate_result)
}
+ PoolKind::Oracle(pool) => {
+ let pool = pool.clone();
+ drop(connections);
+ let mut pool = pool.lock().await;
+ timeout(QUERY_TIMEOUT, db::oracle_driver::execute_query(&mut pool, sql))
+ .await
+ .map_err(|_| format!("Query timed out after {} seconds", QUERY_TIMEOUT.as_secs()))?
+ .map(truncate_result)
+ }
PoolKind::Redis(_) => Err("Use Redis-specific commands".to_string()),
PoolKind::MongoDb(_) => Err("Use MongoDB-specific commands".to_string()),
}
diff --git a/src-tauri/src/commands/schema.rs b/src-tauri/src/commands/schema.rs
index fd100404ec..fd79f65843 100644
--- a/src-tauri/src/commands/schema.rs
+++ b/src-tauri/src/commands/schema.rs
@@ -75,6 +75,13 @@ fn extract_clickhouse(connections: &std::collections::HashMap<String, PoolKind>,
}
}
+fn extract_oracle(connections: &std::collections::HashMap<String, PoolKind>, key: &str) -> Option<std::sync::Arc<tokio::sync::Mutex<db::oracle_driver::OraclePool>>> {
+ match connections.get(key)? {
+ PoolKind::Oracle(pool) => Some(pool.clone()),
+ _ => None,
+ }
+}
+
#[tauri::command]
pub async fn list_databases(
state: State<'_, Arc<AppState>>,
@@ -91,6 +98,11 @@ pub async fn list_databases(
let mut client = client.lock().await;
return db::sqlserver::list_databases(&mut client).await;
}
+ if let Some(pool) = extract_oracle(&connections, &connection_id) {
+ drop(connections);
+ let pool = pool.lock().await;
+ return db::oracle_driver::list_databases(&pool).await;
+ }
}
let connections = state.connections.lock().await;
@@ -120,6 +132,11 @@ pub async fn list_schemas(
let mut client = client.lock().await;
return db::sqlserver::list_schemas(&mut client).await;
}
+ if let Some(pool) = extract_oracle(&connections, &pool_key) {
+ drop(connections);
+ let pool = pool.lock().await;
+ return db::oracle_driver::list_schemas(&pool).await;
+ }
}
let connections = state.connections.lock().await;
@@ -156,6 +173,11 @@ pub async fn list_tables(
let mut client = client.lock().await;
return db::sqlserver::list_tables(&mut client, &schema).await;
}
+ if let Some(pool) = extract_oracle(&connections, &pool_key) {
+ drop(connections);
+ let pool = pool.lock().await;
+ return db::oracle_driver::list_tables(&pool, &schema).await;
+ }
}
let connections = state.connections.lock().await;
@@ -195,6 +217,11 @@ pub async fn get_columns(
let mut client = client.lock().await;
return db::sqlserver::get_columns(&mut client, &schema, &table).await;
}
+ if let Some(pool) = extract_oracle(&connections, &pool_key) {
+ drop(connections);
+ let pool = pool.lock().await;
+ return db::oracle_driver::get_columns(&pool, &schema, &table).await;
+ }
}
let connections = state.connections.lock().await;
@@ -225,6 +252,11 @@ pub async fn list_indexes(
let mut client = client.lock().await;
return db::sqlserver::list_indexes(&mut client, &schema, &table).await;
}
+ if let Some(pool) = extract_oracle(&connections, &pool_key) {
+ drop(connections);
+ let pool = pool.lock().await;
+ return db::oracle_driver::list_indexes(&pool, &schema, &table).await;
+ }
}
let connections = state.connections.lock().await;
@@ -255,6 +287,11 @@ pub async fn list_foreign_keys(
let mut client = client.lock().await;
return db::sqlserver::list_foreign_keys(&mut client, &schema, &table).await;
}
+ if let Some(pool) = extract_oracle(&connections, &pool_key) {
+ drop(connections);
+ let pool = pool.lock().await;
+ return db::oracle_driver::list_foreign_keys(&pool, &schema, &table).await;
+ }
}
let connections = state.connections.lock().await;
@@ -285,6 +322,11 @@ pub async fn list_triggers(
let mut client = client.lock().await;
return db::sqlserver::list_triggers(&mut client, &schema, &table).await;
}
+ if let Some(pool) = extract_oracle(&connections, &pool_key) {
+ drop(connections);
+ let pool = pool.lock().await;
+ return db::oracle_driver::list_triggers(&pool, &schema, &table).await;
+ }
}
let connections = state.connections.lock().await;
@@ -336,6 +378,11 @@ pub async fn get_table_ddl(
let mut client = client.lock().await;
return build_sqlserver_ddl(&mut client, &schema, &table).await;
}
+ if let Some(pool) = extract_oracle(&connections, &pool_key) {
+ drop(connections);
+ let pool = pool.lock().await;
+ return build_oracle_ddl(&pool, &schema, &table).await;
+ }
}
let connections = state.connections.lock().await;
@@ -429,3 +476,35 @@ async fn build_sqlserver_ddl(client: &mut db::sqlserver::SqlServerClient, schema
}
Ok(ddl)
}
+
+async fn build_oracle_ddl(pool: &db::oracle_driver::OraclePool, schema: &str, table: &str) -> Result<String, String> {
+ let columns = db::oracle_driver::get_columns(pool, schema, table).await?;
+ let indexes = db::oracle_driver::list_indexes(pool, schema, table).await?;
+ let fkeys = db::oracle_driver::list_foreign_keys(pool, schema, table).await?;
+
+ let mut ddl = format!("CREATE TABLE \"{schema}\".\"{table}\" (\n");
+ let col_lines: Vec<String> = columns.iter().map(|c| {
+ let mut line = format!(" \"{}\" {}", c.name, c.data_type);
+ if !c.is_nullable { line.push_str(" NOT NULL"); }
+ if let Some(ref def) = c.column_default { line.push_str(&format!(" DEFAULT {def}")); }
+ line
+ }).collect();
+ ddl.push_str(&col_lines.join(",\n"));
+
+ let pks: Vec<&str> = columns.iter().filter(|c| c.is_primary_key).map(|c| c.name.as_str()).collect();
+ if !pks.is_empty() {
+ ddl.push_str(&format!(",\n PRIMARY KEY ({})", pks.iter().map(|k| format!("\"{k}\"")).collect::<Vec<_>>().join(", ")));
+ }
+ for fk in &fkeys {
+ ddl.push_str(&format!(",\n CONSTRAINT \"{}\" FOREIGN KEY (\"{}\") REFERENCES \"{}\"(\"{}\")", fk.name, fk.column, fk.ref_table, fk.ref_column));
+ }
+ ddl.push_str("\n);\n");
+
+ for idx in &indexes {
+ if idx.is_primary { continue; }
+ let unique = if idx.is_unique { "UNIQUE " } else { "" };
+ let cols = idx.columns.iter().map(|c| format!("\"{c}\"")).collect::<Vec<_>>().join(", ");
+ ddl.push_str(&format!("\nCREATE {unique}INDEX \"{}\" ON \"{schema}\".\"{table}\" ({cols});", idx.name));
+ }
+ Ok(ddl)
+}
diff --git a/src-tauri/src/db/mod.rs b/src-tauri/src/db/mod.rs
index f911c375fd..5c04ac8f34 100644
--- a/src-tauri/src/db/mod.rs
+++ b/src-tauri/src/db/mod.rs
@@ -1,6 +1,7 @@
pub mod clickhouse_driver;
pub mod mongo_driver;
pub mod mysql;
+pub mod oracle_driver;
pub mod postgres;
pub mod redis_driver;
pub mod sqlite;
diff --git a/src-tauri/src/db/oracle_driver.rs b/src-tauri/src/db/oracle_driver.rs
new file mode 100644
index 0000000000..bf71cca996
--- /dev/null
+++ b/src-tauri/src/db/oracle_driver.rs
@@ -0,0 +1,250 @@
+use oracle_rs::{Config, Connection};
+use std::time::Instant;
+
+use super::{ColumnInfo, DatabaseInfo, ForeignKeyInfo, IndexInfo, QueryResult, TableInfo, TriggerInfo};
+
+pub struct OraclePool {
+ pub conn: Connection,
+ host: String,
+ port: u16,
+ service: String,
+ user: String,
+ pass: String,
+}
+
+impl OraclePool {
+ pub async fn connect(host: &str, port: u16, service: &str, user: &str, pass: &str) -> Result<Self, String> {
+ let config = Config::new(host, port, service, user, pass);
+ let conn = Connection::connect_with_config(config)
+ .await
+ .map_err(|e| format!("Oracle connection failed: {e}"))?;
+ Ok(Self {
+ conn,
+ host: host.to_string(),
+ port,
+ service: service.to_string(),
+ user: user.to_string(),
+ pass: pass.to_string(),
+ })
+ }
+
+ pub async fn reconnect(&mut self) -> Result<(), String> {
+ let config = Config::new(&self.host, self.port, &self.service, &self.user, &self.pass);
+ self.conn = Connection::connect_with_config(config)
+ .await
+ .map_err(|e| format!("Oracle reconnect failed: {e}"))?;
+ Ok(())
+ }
+}
+
+fn value_to_json(val: &oracle_rs::Value) -> serde_json::Value {
+ match val {
+ oracle_rs::Value::Null => serde_json::Value::Null,
+ oracle_rs::Value::String(s) => serde_json::Value::String(s.clone()),
+ oracle_rs::Value::Integer(n) => serde_json::Value::Number((*n).into()),
+ oracle_rs::Value::Float(f) => serde_json::Number::from_f64(*f)
+ .map(serde_json::Value::Number)
+ .unwrap_or(serde_json::Value::Null),
+ oracle_rs::Value::Boolean(b) => serde_json::Value::Bool(*b),
+ oracle_rs::Value::Json(v) => v.clone(),
+ _ => serde_json::Value::String(format!("{val:?}")),
+ }
+}
+
+pub async fn list_databases(pool: &OraclePool) -> Result<Vec<DatabaseInfo>, String> {
+ let result = pool.conn.query(
+ "SELECT username FROM all_users ORDER BY username",
+ &[],
+ ).await.map_err(|e| e.to_string())?;
+ Ok(result.rows.iter().map(|row| {
+ DatabaseInfo {
+ name: row.get_string(0).unwrap_or("").to_string(),
+ }
+ }).collect())
+}
+
+pub async fn list_schemas(pool: &OraclePool) -> Result<Vec<String>, String> {
+ let result = pool.conn.query(
+ "SELECT username FROM all_users ORDER BY username",
+ &[],
+ ).await.map_err(|e| e.to_string())?;
+ Ok(result.rows.iter().map(|row| {
+ row.get_string(0).unwrap_or("").to_string()
+ }).collect())
+}
+
+pub async fn list_tables(pool: &OraclePool, schema: &str) -> Result<Vec<TableInfo>, String> {
+ let sql = format!(
+ "SELECT table_name, 'TABLE' AS table_type FROM all_tables WHERE owner = '{s}' \
+ UNION ALL \
+ SELECT view_name, 'VIEW' FROM all_views WHERE owner = '{s}' \
+ ORDER BY 1",
+ s = schema.replace('\'', "''")
+ );
+ let result = pool.conn.query(&sql, &[]).await.map_err(|e| e.to_string())?;
+ Ok(result.rows.iter().map(|row| {
+ TableInfo {
+ name: row.get_string(0).unwrap_or("").to_string(),
+ table_type: row.get_string(1).unwrap_or("TABLE").to_string(),
+ }
+ }).collect())
+}
+
+pub async fn get_columns(pool: &OraclePool, schema: &str, table: &str) -> Result<Vec<ColumnInfo>, String> {
+ let s = schema.replace('\'', "''");
+ let t = table.replace('\'', "''");
+
+ let pk_result = pool.conn.query(
+ &format!(
+ "SELECT cols.COLUMN_NAME FROM ALL_CONS_COLUMNS cols \
+ JOIN ALL_CONSTRAINTS cons ON cols.CONSTRAINT_NAME = cons.CONSTRAINT_NAME AND cols.OWNER = cons.OWNER \
+ WHERE cons.CONSTRAINT_TYPE = 'P' AND cons.OWNER = '{s}' AND cons.TABLE_NAME = '{t}'"
+ ),
+ &[],
+ ).await.map_err(|e| e.to_string())?;
+ let pk_names: std::collections::HashSet<String> = pk_result.rows.iter()
+ .filter_map(|row| row.get_string(0).map(|s| s.to_string()))
+ .collect();
+
+ let col_result = pool.conn.query(
+ &format!(
+ "SELECT COLUMN_NAME, DATA_TYPE, NULLABLE \
+ FROM ALL_TAB_COLUMNS \
+ WHERE OWNER = '{s}' AND TABLE_NAME = '{t}' \
+ ORDER BY COLUMN_ID"
+ ),
+ &[],
+ ).await.map_err(|e| e.to_string())?;
+
+ Ok(col_result.rows.iter().map(|row| {
+ let name = row.get_string(0).unwrap_or("").to_string();
+ ColumnInfo {
+ is_primary_key: pk_names.contains(&name),
+ name,
+ data_type: row.get_string(1).unwrap_or("").to_string(),
+ is_nullable: row.get_string(2).unwrap_or("N") == "Y",
+ column_default: None,
+ extra: None,
+ }
+ }).collect())
+}
+
+pub async fn list_indexes(pool: &OraclePool, schema: &str, table: &str) -> Result<Vec<IndexInfo>, String> {
+ let sql = format!(
+ "SELECT i.INDEX_NAME, \
+ LISTAGG(ic.COLUMN_NAME, ',') WITHIN GROUP (ORDER BY ic.COLUMN_POSITION) AS columns, \
+ i.UNIQUENESS, \
+ CASE WHEN c.CONSTRAINT_TYPE = 'P' THEN 1 ELSE 0 END AS IS_PK \
+ FROM ALL_INDEXES i \
+ JOIN ALL_IND_COLUMNS ic ON i.INDEX_NAME = ic.INDEX_NAME AND i.TABLE_OWNER = ic.TABLE_OWNER \
+ LEFT JOIN ALL_CONSTRAINTS c ON i.INDEX_NAME = c.INDEX_NAME AND i.TABLE_OWNER = c.OWNER \
+ AND c.CONSTRAINT_TYPE = 'P' \
+ WHERE i.TABLE_OWNER = '{s}' AND i.TABLE_NAME = '{t}' \
+ GROUP BY i.INDEX_NAME, i.UNIQUENESS, c.CONSTRAINT_TYPE \
+ ORDER BY i.INDEX_NAME",
+ s = schema.replace('\'', "''"), t = table.replace('\'', "''")
+ );
+ let result = pool.conn.query(&sql, &[]).await.map_err(|e| e.to_string())?;
+ Ok(result.rows.iter().map(|row| {
+ let cols_str = row.get_string(1).unwrap_or("");
+ IndexInfo {
+ name: row.get_string(0).unwrap_or("").to_string(),
+ columns: cols_str.split(',').map(|s| s.to_string()).collect(),
+ is_unique: row.get_string(2).unwrap_or("") == "UNIQUE",
+ is_primary: row.get_i64(3).unwrap_or(0) == 1,
+ }
+ }).collect())
+}
+
+pub async fn list_foreign_keys(pool: &OraclePool, schema: &str, table: &str) -> Result<Vec<ForeignKeyInfo>, String> {
+ let sql = format!(
+ "SELECT c.CONSTRAINT_NAME, cc.COLUMN_NAME, rc.TABLE_NAME, rcc.COLUMN_NAME \
+ FROM ALL_CONSTRAINTS c \
+ JOIN ALL_CONS_COLUMNS cc ON c.CONSTRAINT_NAME = cc.CONSTRAINT_NAME AND c.OWNER = cc.OWNER \
+ JOIN ALL_CONSTRAINTS rc ON c.R_CONSTRAINT_NAME = rc.CONSTRAINT_NAME AND c.R_OWNER = rc.OWNER \
+ JOIN ALL_CONS_COLUMNS rcc ON rc.CONSTRAINT_NAME = rcc.CONSTRAINT_NAME AND rc.OWNER = rcc.OWNER \
+ WHERE c.CONSTRAINT_TYPE = 'R' AND c.OWNER = '{s}' AND c.TABLE_NAME = '{t}' \
+ ORDER BY c.CONSTRAINT_NAME",
+ s = schema.replace('\'', "''"), t = table.replace('\'', "''")
+ );
+ let result = pool.conn.query(&sql, &[]).await.map_err(|e| e.to_string())?;
+ Ok(result.rows.iter().map(|row| {
+ ForeignKeyInfo {
+ name: row.get_string(0).unwrap_or("").to_string(),
+ column: row.get_string(1).unwrap_or("").to_string(),
+ ref_table: row.get_string(2).unwrap_or("").to_string(),
+ ref_column: row.get_string(3).unwrap_or("").to_string(),
+ }
+ }).collect())
+}
+
+pub async fn list_triggers(pool: &OraclePool, schema: &str, table: &str) -> Result<Vec<TriggerInfo>, String> {
+ let sql = format!(
+ "SELECT TRIGGER_NAME, TRIGGERING_EVENT, TRIGGER_TYPE \
+ FROM ALL_TRIGGERS \
+ WHERE OWNER = '{s}' AND TABLE_NAME = '{t}' \
+ ORDER BY TRIGGER_NAME",
+ s = schema.replace('\'', "''"), t = table.replace('\'', "''")
+ );
+ let result = pool.conn.query(&sql, &[]).await.map_err(|e| e.to_string())?;
+ Ok(result.rows.iter().map(|row| {
+ TriggerInfo {
+ name: row.get_string(0).unwrap_or("").to_string(),
+ event: row.get_string(1).unwrap_or("").to_string(),
+ timing: row.get_string(2).unwrap_or("").to_string(),
+ }
+ }).collect())
+}
+
+pub async fn execute_query(pool: &mut OraclePool, sql: &str) -> Result<QueryResult, String> {
+ let start = Instant::now();
+ let sql = sql.trim().trim_end_matches(';');
+ let trimmed = sql.to_uppercase();
+
+ if trimmed.starts_with("SELECT")
+ || trimmed.starts_with("WITH")
+ || trimmed.starts_with("SHOW")
+ || trimmed.starts_with("DESCRIBE")
+ || trimmed.starts_with("EXPLAIN")
+ {
+ let result = pool.conn.query(sql, &[]).await.map_err(|e| e.to_string())?;
+ let columns: Vec<String> = result.columns.iter().map(|c| c.name.clone()).collect();
+ let rows: Vec<Vec<serde_json::Value>> = result.rows.iter().map(|row| {
+ (0..columns.len()).map(|i| {
+ row.get(i)
+ .map(|v| value_to_json(v))
+ .unwrap_or(serde_json::Value::Null)
+ }).collect()
+ }).collect();
+
+ Ok(QueryResult {
+ columns,
+ rows,
+ affected_rows: 0,
+ execution_time_ms: start.elapsed().as_millis(),
+ truncated: false,
+ })
+ } else {
+ match pool.conn.execute(sql, &[]).await {
+ Ok(result) => {
+ pool.conn.commit().await.map_err(|e| e.to_string())?;
+ Ok(QueryResult {
+ columns: vec![],
+ rows: vec![],
+ affected_rows: result.rows_affected,
+ execution_time_ms: start.elapsed().as_millis(),
+ truncated: false,
+ })
+ }
+ Err(e) => {
+ let msg = e.to_string();
+ if msg.contains("Server rejected") || msg.contains("closed the connection") {
+ let _ = pool.reconnect().await;
+ Err("Operation failed — possibly a constraint violation (foreign key, unique, or check constraint).".to_string())
+ } else {
+ Err(msg)
+ }
+ }
+ }
+ }
+}
diff --git a/src-tauri/src/models/connection.rs b/src-tauri/src/models/connection.rs
index 62616f7610..795c8c6184 100644
--- a/src-tauri/src/models/connection.rs
+++ b/src-tauri/src/models/connection.rs
@@ -41,6 +41,8 @@ pub enum DatabaseType {
SqlServer,
#[serde(rename = "mongodb")]
MongoDb,
+ #[serde(rename = "oracle")]
+ Oracle,
}
impl ConnectionConfig {
@@ -84,6 +86,10 @@ impl ConnectionConfig {
format!("mongodb://{}:{}@{host}:{port}{db_part}", self.username, self.password)
}
}
+ DatabaseType::Oracle => format!(
+ "oracle://{}:{}@{host}:{port}{db_part}",
+ self.username, self.password
+ ),
}
}
}
diff --git a/src/App.vue b/src/App.vue
index d1f287f4ec..3eb31ab0f3 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -277,7 +277,7 @@ function quoteIdent(tab: ActiveTab, name: string): string {
function qualifiedTableName(tab: NonNullable<typeof activeTab.value>): string {
const config = connectionStore.getConfig(tab.connectionId);
if (!tab.tableMeta) return "";
- if (config?.db_type === "postgres" && tab.tableMeta.schema) {
+ if ((config?.db_type === "postgres" || config?.db_type === "oracle") && tab.tableMeta.schema) {
return `${quoteIdent(tab, tab.tableMeta.schema)}.${quoteIdent(tab, tab.tableMeta.tableName)}`;
}
return quoteIdent(tab, tab.tableMeta.tableName);
@@ -293,9 +293,16 @@ function buildTableSql(
tab: NonNullable<typeof activeTab.value>,
options: { orderBy?: string; limit?: number; offset?: number } = {},
): string {
+ const config = connectionStore.getConfig(tab.connectionId);
const limit = options.limit ?? 100;
const orderBy = options.orderBy ?? defaultOrderBy(tab);
const order = orderBy ? ` ORDER BY ${orderBy}` : "";
+
+ if (config?.db_type === "oracle") {
+ const offset = options.offset ? ` OFFSET ${options.offset} ROWS` : "";
+ return `SELECT * FROM ${qualifiedTableName(tab)}${order}${offset} FETCH FIRST ${limit} ROWS ONLY`;
+ }
+
const offset = options.offset ? ` OFFSET ${options.offset}` : "";
return `SELECT * FROM ${qualifiedTableName(tab)}${order} LIMIT ${limit}${offset};`;
}
diff --git a/src/components/connection/ConnectionDialog.vue b/src/components/connection/ConnectionDialog.vue
index 5d01f43d07..2cf618825c 100644
--- a/src/components/connection/ConnectionDialog.vue
+++ b/src/components/connection/ConnectionDialog.vue
@@ -87,6 +87,7 @@ function onDbTypeChange(val: string) {
mongodb: { type: "mongodb", port: 27017, user: "" },
clickhouse: { type: "clickhouse", port: 8123, user: "default" },
sqlserver: { type: "sqlserver", port: 1433, user: "sa" },
+ oracle: { type: "oracle", port: 1521, user: "system" },
tidb: { type: "mysql", port: 4000, user: "root" },
oceanbase: { type: "mysql", port: 2881, user: "root" },
goldendb: { type: "mysql", port: 3306, user: "root" },
@@ -110,6 +111,7 @@ function onDbTypeChange(val: string) {
const iconTypeMap: Record<string, string> = {
mysql: "mysql", postgres: "postgres", sqlite: "sqlite", redis: "redis",
mongodb: "mongodb", duckdb: "duckdb", clickhouse: "clickhouse", sqlserver: "sqlserver",
+ oracle: "oracle",
mariadb: "mariadb", tidb: "tidb", oceanbase: "mysql", goldendb: "mysql",
opengauss: "postgres", gaussdb: "postgres", kingbase: "postgres", vastbase: "postgres",
};
@@ -123,6 +125,7 @@ const dbOptions = [
{ value: "duckdb", label: "DuckDB" },
{ value: "clickhouse", label: "ClickHouse" },
{ value: "sqlserver", label: "SQL Server" },
+ { value: "oracle", label: "Oracle" },
{ value: "mariadb", label: "MariaDB" },
];
diff --git a/src/components/icons/DatabaseIcon.vue b/src/components/icons/DatabaseIcon.vue
index e40fc0b932..5698989a51 100644
--- a/src/components/icons/DatabaseIcon.vue
+++ b/src/components/icons/DatabaseIcon.vue
@@ -21,10 +21,19 @@ const brandIcons: Record<string, { path: string; color: string; viewBox?: string
duckdb: { path: siDuckdb.path, color: `#${siDuckdb.hex}` },
mariadb: { path: siMariadb.path, color: `#${siMariadb.hex}` },
tidb: { path: siTidb.path, color: `#${siTidb.hex}` },
+ oracle: {
+ viewBox: "0 0 32 32",
+ color: "#F80000",
+ path: "M21.88 5.88H10.125C4.536 5.88.005 10.407 0 15.995c-.005 5.589 4.527 10.12 10.115 10.125H21.88C27.469 26.12 32 21.588 32 16S27.469 5.88 21.88 5.88m-.255 16.672H10.38c-8.563-.172-8.563-12.932 0-13.104h11.245c8.735 0 8.735 13.104 0 13.104",
+ },
+ sqlserver: {
+ viewBox: "0 0 128 128",
+ color: "#CC2927",
+ path: "M52.935 0v.002c-.426-.058-7.306 2.42-11.742 4.223c-5.988 2.44-10.636 4.766-13.504 6.78c-.926.657-2.054 1.75-2.475 2.37l-.007-.021a1 1 0 0 0-.069.148c-.022.04-.052.086-.066.12a1.8 1.8 0 0 0-.115.66l.064.06c.017.207.065.44.168.695c.252.62.988 1.376 1.822 2.15c0 0 8.621 8.409 9.668 9.61c4.766 5.503 6.84 10.927 7.034 18.406c.117 4.805-.796 9.03-3.063 13.932c-4.03 8.796-12.535 18.504-25.652 29.276l.199-.067c-.09.072-.208.174-.295.242c-1.57 1.24-3.896 3.565-5.078 5.038c-1.764 2.209-3.157 4.553-3.758 6.355c-1.066 3.255-.543 6.548 1.51 9.59c2.636 3.875 7.887 7.83 14.01 10.521c3.12 1.377 8.368 3.14 12.322 4.127c6.567 1.667 19.28 3.469 26.273 3.739c1.414.059 3.312.059 3.39 0c.155-.097 1.241-2.168 2.501-4.744c4.3-8.778 7.399-17.013 9.086-24.047c1.007-4.262 1.801-9.94 2.324-16.663c.136-1.88.194-8.177.078-10.308c-.175-3.487-.483-6.316-.968-9.086a4 4 0 0 1-.07-.573c15.578-4.628 32.768-8.821 44.187-10.568l1.764-.271l-.272-.428c-1.55-2.403-2.615-3.894-3.894-5.483c-3.72-4.61-8.233-8.349-13.756-11.449c-7.595-4.244-17.419-7.557-29.858-10.018c-2.344-.465-7.495-1.357-11.68-1.996l-.39-.699c-2.287-4.03-4.805-9.027-6.278-12.398c-1.142-2.616-2.228-5.639-2.828-7.809C53.187.098 53.15.02 52.935 0m-.31.988h.02c.018.02.095.564.173 1.203c.33 2.712.931 5.328 1.881 8.157c.716 2.13.716 2.015-.117 1.763c-1.976-.542-10.83-2.072-17.244-2.964c-1.027-.135-1.899-.271-1.899-.291c-.077-.078 4.63-2.537 6.703-3.506c2.654-1.22 9.94-4.265 10.483-4.362M33.947 9.67l.756.252c4.108 1.395 14.434 3.373 20.13 3.838c.64.058 1.182.115 1.2.115c.02.02-.52.31-1.219.639c-2.75 1.376-5.775 3.061-7.867 4.36c-.476.296-.912.546-1.127.648l-1.932-.315l-1.824-1.787a804 804 0 0 0-7.11-6.84zm-.775.602l2.732 3.41c1.492 1.88 3.003 3.72 3.332 4.127c.291.359.503.622.543.7c-1.935-.337-4.006-.708-5.6-1.052c-1.163-.252-3.39-.775-5.134-1.375c-.18-.07-.385-.146-.58-.219v-.205c.02-1.3 1.666-3.238 4.455-5.213zm23.173 4.646q.024-.01.04.004c.077 0 .172.172.404.695c.66 1.453 2.715 5.367 3.219 6.123l.064.104a1194 1194 0 0 1-10.977-1.79a3 3 0 0 1 .372-.232c2.035-1.124 4.088-2.557 5.91-4.088c.445-.368.851-.715.93-.773a.1.1 0 0 1 .038-.043m-26.138 3.275c.019-.018.329.1.736.235a50 50 0 0 0 2.81.851a143 143 0 0 0 2.557.678c1.162.29 2.132.563 2.15.563c.137.136 2.094 6.394 2.753 8.797c.252.91.446 1.685.427 1.685c-.02.02-.234-.31-.486-.756c-2.267-3.99-5.851-8.04-9.998-11.297c-.542-.387-.95-.736-.95-.756zm9.513 2.618c0 .038 0 .02.02.02c.098 0 .524.057 1.047.173c3.293.736 9.203 1.86 12.98 2.5c.64.097 1.143.214 1.143.252c0 .04-.23.175-.522.33c-.64.33-3.217 1.86-4.07 2.44c-2.15 1.435-4.087 2.983-5.482 4.378a80 80 0 0 1-1.047 1.028s-.115-.33-.213-.737c-.697-2.694-2.15-6.684-3.469-9.494c-.213-.445-.387-.852-.387-.89m16.8 3.215c.115.04.31.699.697 2.152a31.7 31.7 0 0 1 .93 8.873c-.04.814-.079 1.57-.118 1.668l-.057.191l-1.007-.33c-2.073-.658-5.444-1.645-8.33-2.459c-1.648-.446-2.985-.852-2.985-.89c0-.117 2.403-2.52 3.43-3.43c1.956-1.725 7.264-5.832 7.44-5.775m1.335.195c.058-.058 8.024 1.316 11.647 2.014c2.694.523 6.607 1.338 6.84 1.435c.115.04-.291.269-1.59.852c-5.115 2.305-8.914 4.38-12.692 6.898c-.988.66-1.822 1.201-1.84 1.201c-.02 0-.039-.562-.039-1.24c0-3.681-.734-7.401-2.091-10.54c-.136-.31-.254-.601-.235-.62m20.596 4.068c.058.057-.193 1.629-.426 2.559c-.698 2.887-2.576 7.17-4.88 11.2c-.409.716-.778 1.297-.817 1.316s-.558-.273-1.16-.622c-2.247-1.318-4.806-2.555-7.596-3.718c-.775-.33-1.454-.601-1.473-.641c-.136-.115 6.104-4.242 9.397-6.219c2.617-1.589 6.879-3.952 6.955-3.875m1.475.233c.174 0 3.7.968 5.54 1.511c4.554 1.356 9.784 3.275 13.194 4.825l1.414.638l-.986.233c-8.33 1.918-15.463 4.129-22.342 6.918c-.562.233-1.066.425-1.104.425s.157-.444.409-.986c2.073-4.399 3.408-8.991 3.738-12.906c.019-.368.079-.658.137-.658m-35.11 8.06c.058-.058 2.751.582 4.205.989c2.21.62 6.899 2.19 6.899 2.304c0 .02-.525.466-1.145 1.008c-2.538 2.112-4.98 4.341-7.906 7.17c-.871.833-1.606 1.51-1.645 1.51c-.04 0-.059-.115-.04-.27c.445-3.255.35-7.44-.27-11.683c-.06-.543-.117-1.009-.098-1.028m56.596.059c.038.039-1.24 2.052-2.055 3.195c-1.162 1.667-2.867 3.877-6.722 8.72a1290 1290 0 0 0-5.076 6.413c-.775.969-1.415 1.783-1.436 1.783c-.018 0-.27-.35-.541-.775c-2.17-3.256-4.767-6.103-7.848-8.66a45 45 0 0 0-1.431-1.164c-.214-.155-.39-.31-.39-.33c0-.057 3.294-1.472 5.794-2.479c4.38-1.783 10.345-3.913 14.822-5.29c2.344-.735 4.844-1.452 4.883-1.413m1.492.387c.077-.02.543.214 1.104.543c4.709 2.693 9.32 6.162 12.963 9.726c1.027 1.008 3.564 3.641 3.525 3.66c0 0-.891.08-1.937.157c-8.157.62-18.6 2.343-28.635 4.765c-.68.155-1.28.291-1.319.291s.716-.756 1.666-1.666c5.89-5.677 8.583-9.261 11.76-15.656c.446-.948.834-1.762.873-1.82m-43.148 4.418c.27.058 2.788 1.239 4.687 2.189c1.744.871 4.361 2.266 4.496 2.383c.02.019-.91.503-2.054 1.066a135 135 0 0 0-10.018 5.522c-.93.562-1.704 1.027-1.723 1.027c-.078 0-.058-.078.465-1.027c1.744-3.177 3.14-6.975 3.934-10.676c.077-.29.155-.484.213-.484m-2.52.464c.058.058-.6 2.442-1.008 3.74c-.795 2.46-2.131 5.54-3.43 7.866c-.31.542-.775 1.338-1.027 1.783l-.484.774l-1.084-1.045c-1.26-1.22-2.287-1.978-3.604-2.657c-.524-.27-.93-.502-.93-.54c0-.156 3.314-3.159 5.852-5.329c1.82-1.57 5.657-4.65 5.715-4.592m15.404 6.336l.95.62c2.17 1.414 4.726 3.295 6.683 4.94c1.104.91 3.235 2.83 3.662 3.294l.233.252l-1.57.447c-8.874 2.46-15.733 4.649-23.735 7.594c-.892.33-1.647.6-1.705.6c-.116 0-.213.096 1.783-1.745c5.115-4.707 9.65-9.898 13.022-14.955zm-4.05 1.008c.04.04-2.614 3.777-4.203 5.889c-1.9 2.519-5.272 6.743-7.598 9.494c-.968 1.144-1.8 2.092-1.84 2.111c-.058.02-.078-.27-.078-.716c0-2.344-.599-4.844-1.645-6.975c-.446-.891-.523-1.104-.425-1.201c.368-.33 6.004-3.545 9.568-5.463c2.404-1.28 6.163-3.177 6.22-3.139zM44.1 55.26c.057 0 .502.233 1.007.504a21.3 21.3 0 0 1 3.332 2.248c.04.038-.464.446-1.123.93c-1.84 1.317-4.63 3.43-6.258 4.728c-1.705 1.356-1.763 1.394-1.57 1.104c1.28-1.957 1.92-3.062 2.598-4.477a36 36 0 0 0 1.627-4.05c.155-.56.347-.987.386-.987zm6.53 5.113c.097-.018.213.157.735.932c1.104 1.647 1.957 3.857 2.17 5.639l.039.386l-2.654 1.028c-4.747 1.84-9.126 3.662-12.09 5.02a217 217 0 0 0-3.237 1.548c-.95.484-1.724.853-1.724.834s.6-.465 1.336-1.008c5.794-4.204 10.813-8.816 14.572-13.427c.407-.484.775-.93.813-.95zm-3.003.737v.002c.078.077-2.132 2.576-3.643 4.107c-3.74 3.816-7.441 6.801-12.033 9.707c-.582.368-1.104.697-1.162.735c-.135.078.038-.116 2.054-2.305a53 53 0 0 0 3.352-3.97c.736-.95.871-1.086 1.937-1.84c2.85-2.056 9.418-6.513 9.495-6.436m25.974 2.3c.274 1.057.78 6.126.918 9.481c.04.795.019 1.318-.021 1.318c-.154 0-3.273-1.84-5.5-3.236c-1.93-1.215-5.579-3.634-6.18-4.113a359 359 0 0 1 10.783-3.45m-12.867 4.192c.254.11.635.32 1.404.795c3.991 2.5 9.418 5.522 11.743 6.53c.716.31.793.193-.854 1.318c-3.526 2.402-7.924 4.765-13.31 7.148c-.95.426-1.745.756-1.764.756c-.04 0 .077-.486.232-1.067c1.297-4.825 2.036-9.705 2.075-13.619c.01-.977.014-1.46.039-1.707zm-2.965 1.055c.094.476.021 4.368-.127 5.494a49.4 49.4 0 0 1-1.78 8.428c-.214.717-.41 1.319-.448 1.357c-.078.097-2.732-2.5-3.604-3.508c-1.51-1.744-2.692-3.486-3.564-5.191c-.404-.79-.987-2.205-1.055-2.518a345 345 0 0 1 8.592-3.355c.617-.232 1.343-.473 1.986-.707m-12.603 4.9c.047.069.163.327.271.652c.62 1.685 2.013 4.165 3.215 5.754c1.318 1.744 3.043 3.605 4.477 4.825c.465.387.89.756.949.814c.116.117.155.097-3.004 1.299c-3.66 1.395-7.652 2.79-12.225 4.262a610 610 0 0 0-3.275 1.066c-.175.058-.114-.04.389-.834c2.267-3.544 5.714-10.5 7.652-15.422c.33-.853.659-1.706.717-1.9c.027-.095.066-.15.103-.211l.73-.305zm-4.01 1.7c-.132.39-.973 2.151-1.842 3.853c-1.88 3.663-3.933 7.267-6.684 11.646c-.466.755-.91 1.453-.97 1.53c-.096.136-.135.098-.446-.502c-.659-1.3-1.2-2.965-1.492-4.496c-.29-1.511-.232-4.146.098-5.774c.15-.717.216-.987.36-1.16a225 225 0 0 1 10.976-5.098zm33.479 1.2v.813c0 4.321-.465 10.25-1.143 14.57c-.116.756-.213 1.377-.232 1.397c0 0-.563-.156-1.221-.35a50 50 0 0 1-8.912-3.816c-1.88-1.027-4.61-2.714-4.533-2.791c.019-.02.832-.445 1.78-.95c3.799-1.975 7.441-4.107 10.6-6.22c1.182-.794 2.963-2.071 3.35-2.42zm-48.048 5.737c.074.004.052.163-.062.851a28 28 0 0 0-.213 2.07c-.155 2.83.31 4.925 1.705 7.792c.388.794.698 1.453.678 1.472c-.135.117-12.962 3.875-16.992 4.979c-1.201.33-2.247.62-2.325.639c-.136.04-.155.021-.097-.309c.446-2.848 2.617-6.568 5.64-9.707c2.014-2.093 3.622-3.314 6.373-4.883c.921-.524 2.066-1.163 3.057-1.71q1.107-.602 2.236-1.194m30.221 5.404h.002c.02-.02.483.232 1.045.56c4.147 2.404 9.921 4.633 14.842 5.776l.445.096l-.619.35c-2.576 1.433-11.045 4.96-19.705 8.195c-1.26.465-2.498.93-2.73 1.027c-.233.097-.448.155-.448.135s.35-.698.795-1.531c2.422-4.534 4.863-10.055 6.104-13.891c.155-.368.25-.697.27-.717zm-3.08 1.006h.002c.02.02-.136.428-.33.893c-1.686 4.088-3.895 8.545-6.724 13.543c-.716 1.28-1.317 2.306-1.336 2.306s-.601-.35-1.3-.775c-4.106-2.52-7.75-5.62-10.132-8.623l-.35-.426l1.764-.484c6.316-1.724 11.684-3.584 17.012-5.87c.756-.31 1.375-.564 1.394-.564m19.143 6.686c.02.446-.967 4.437-1.781 7.324c-.678 2.422-1.26 4.32-2.327 7.672c-.464 1.474-.87 2.693-.89 2.693s-.135-.018-.252-.056c-5.754-1.047-10.908-2.501-15.752-4.438c-1.356-.543-3.293-1.415-3.41-1.512c-.038-.039 1.124-.581 2.597-1.22c8.816-3.856 17.96-8.235 21.1-10.114c.368-.233.657-.35.715-.35zM28.677 96.8c.04.04-2.423 3.585-5.87 8.41c-1.203 1.686-2.597 3.661-3.12 4.397a78 78 0 0 0-1.764 2.596l-.814 1.261l-.871-.738c-1.027-.853-2.809-2.673-3.604-3.68c-1.666-2.073-2.791-4.264-3.236-6.26c-.214-.93-.214-1.394-.02-1.45a1459 1459 0 0 1 10.31-2.424a862 862 0 0 0 6.935-1.627c1.124-.271 2.035-.485 2.054-.485m2.479.95l.621.697c2.79 3.12 5.637 5.425 9.086 7.44c.62.35 1.086.659 1.047.679c-.135.096-11.974 4.3-17.457 6.2a463 463 0 0 1-5.639 1.956c-.019 0-.194-.117-.387-.252l-.35-.252l.563-.814c1.82-2.635 4.107-5.521 9.086-11.528zm15.463 11.062c.019-.02.87.29 1.918.68c2.519.949 4.513 1.55 7.187 2.228c3.294.833 8.061 1.646 10.872 1.88c.426.037.657.076.58.134c-.136.077-2.985 1.028-5.077 1.686c-3.333 1.047-13.504 4.05-21.797 6.433a219 219 0 0 1-2.925.834c-.194.038-.834-.138-.834-.215c0-.038.465-.638 1.027-1.297c2.79-3.333 5.561-7.054 7.867-10.58c.64-.969 1.182-1.764 1.182-1.783m-3.412.098h.002c.019.02-1.357 2.227-3.76 6.025c-1.026 1.608-2.17 3.432-2.576 4.07c-.388.62-.971 1.59-1.3 2.131l-.56.987l-.29-.076c-.699-.195-5.601-1.919-6.9-2.442a48 48 0 0 1-4.513-2.072c-1.55-.834-3.487-2.074-3.332-2.113c.038-.02 2.692-.736 5.889-1.608c8.485-2.306 13.194-3.642 16.275-4.611c.562-.175 1.046-.311 1.065-.291m24.123 5.656h.021c.077.195-3.063 8.913-4.207 11.664c-.25.62-.348.776-.484.756c-.33-.02-4.881-.657-7.652-1.064c-4.824-.736-12.925-2.15-14.958-2.616l-.464-.097l2.886-.659c6.2-1.395 9.184-2.15 12.207-3.08a86 86 0 0 0 11.413-4.4c.6-.27 1.102-.483 1.238-.502z",
+ },
};
const letterIcons: Record<string, { letter: string; color: string }> = {
- sqlserver: { letter: "S", color: "#CC2927" },
oceanbase: { letter: "O", color: "#0064FF" },
opengauss: { letter: "G", color: "#34A853" },
gaussdb: { letter: "G", color: "#CF0A2C" },
diff --git a/src/components/sidebar/TreeItem.vue b/src/components/sidebar/TreeItem.vue
index 59f5d76ab5..037ccfc9d7 100644
--- a/src/components/sidebar/TreeItem.vue
+++ b/src/components/sidebar/TreeItem.vue
@@ -144,7 +144,7 @@ async function openData() {
if (!(node.type === "table" || node.type === "view") || !node.connectionId || !node.database) return;
await connectionStore.ensureConnected(node.connectionId);
const config = connectionStore.getConfig(node.connectionId);
- const qualifiedName = config?.db_type === "postgres" && node.schema
+ const qualifiedName = (config?.db_type === "postgres" || config?.db_type === "oracle") && node.schema
? `${quoteIdent(node.schema)}.${quoteIdent(node.label)}`
: quoteIdent(node.label);
const tabId = queryStore.createTab(node.connectionId, node.database, node.label, "data");
@@ -153,7 +153,9 @@ async function openData() {
const columns = await api.getColumns(node.connectionId, node.database, querySchema, node.label);
const pks = columns.filter((c) => c.is_primary_key).map((c) => c.name);
const order = pks.length ? ` ORDER BY ${pks.map((pk) => `${quoteIdent(pk)} ASC`).join(", ")}` : "";
- const sql = `SELECT * FROM ${qualifiedName}${order} LIMIT 100;`;
+ const sql = config?.db_type === "oracle"
+ ? `SELECT * FROM ${qualifiedName}${order} FETCH FIRST 100 ROWS ONLY`
+ : `SELECT * FROM ${qualifiedName}${order} LIMIT 100;`;
queryStore.updateSql(tabId, sql);
queryStore.setTableMeta(tabId, {
schema: node.schema,
diff --git a/src/types/database.ts b/src/types/database.ts
index 14f3ebedcb..cf59ce9e20 100644
--- a/src/types/database.ts
+++ b/src/types/database.ts
@@ -1,4 +1,4 @@
-export type DatabaseType = "mysql" | "postgres" | "sqlite" | "redis" | "duckdb" | "clickhouse" | "sqlserver" | "mongodb";
+export type DatabaseType = "mysql" | "postgres" | "sqlite" | "redis" | "duckdb" | "clickhouse" | "sqlserver" | "mongodb" | "oracle";
export interface ConnectionConfig {
id: string;