mysql 提取 schema,table,column names
参考:
https://dzone.com/articles/how-use-linkedin-market-your
表空间信息
https://coderanch.com/t/300498/databases/Java-find-List-tablespaces-database
getCatalogs()
存储过程
https://dev.mysql.com/doc/refman/5.7/en/routines-table.html
注释
https://dev.mysql.com/doc/refman/8.0/en/columns-table.html
外键
https://dev.mysql.com/doc/refman/5.5/en/constraint-foreign-key.html
package com.dataconnect.test.util;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SchemaDetailsTest {
private static Logger log = LoggerFactory
.getLogger(SchemaDetailsTest.class);
public static void main(String args[]) throws Exception {
String databaseName = "myDbName";
String userName = "username";
String password = "password";
String mySQLPort = "3306";
String hostUrl = "127.0.0.1";
// Setup the connection with the DB
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://" + hostUrl
+ ":" + mySQLPort, userName, password);
// --- LISTING DATABASE SCHEMA NAMES ---
ResultSet resultSet = conn.getMetaData().getCatalogs();
while (resultSet.next()) {
log.info("Schema Name = " + resultSet.getString("TABLE_CAT"));
}
resultSet.close();
// --- LISTING DATABASE TABLE NAMES ---
String[] types = { "TABLE" };
resultSet = conn.getMetaData()
.getTables(databaseName, null, "%", types);
String tableName = "";
while (resultSet.next()) {
tableName = resultSet.getString(3);
log.info("Table Name = " + tableName);
}
resultSet.close();
// --- LISTING DATABASE COLUMN NAMES ---
DatabaseMetaData meta = conn.getMetaData();
resultSet = meta.getColumns(databaseName, null, tableName, "%");
while (resultSet.next()) {
log.info("Column Name of table " + tableName + " = "
+ resultSet.getString(4));
}
}
}
mysql 提取 schema,table,column names的更多相关文章
- Oracle :value too large for column "SCHEMA"."TABLE"."COLUMN" (actual: 519, maximum: 500)的解决方案
原因:我是使用 CREATE TABLE XXX AS subquery 进行创建的数据表,主要是将相关的数据聚合在一起,然后通过导出为SQL脚本文件,进行导入到新库中,导致部分INSERT INTO ...
- mysql切换数据库提示警告:Reading table information for completion of table and column names
登录数据库后,选择数据库时发现以下提示, mysql> use testReading table information for completion of table and column ...
- MySQL Reading table information for completion of table and column names
打开数据库是发现提示: mysql> show databases; +--------------------+ | Database | +--------------------+ | b ...
- Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -
mysql -A不预读数据库信息(use dbname 更快)—Reading table information for completion of table and column names Y ...
- 解决:Reading table information for completion of table and column names
mysql -A不预读数据库信息(use dbname 更快)—Reading table information for completion of table and column names Y ...
- Reading table information for completion of table and column names
mysql> use ad_detail_page;Reading table information for completion of table and column namesYou c ...
- msyql error: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
mysql> use mydb Reading table information for completion of table and column names You can turn o ...
- Replication-Replication Distribution Subsystem: agent xxxxxx failed. Column names in each table must be unique
最近遇到一个关于发布订阅(Replication)的奇葩问题,特此记录一下这个案例.我们一SQL SERVER数据库服务器出现大量告警.告警信息如下所示: DESCRIPTION: Replicati ...
- MySQL 8 mysql system schema
在大的分类上:mysql schema包括存储数据库对象元数据的数据字典表和用于其他操作目的的系统表 数据字典表和系统表一般使用InnoDB存储引擎 与之前的版本不同,数据字典表和系统表存储在数据目录 ...
随机推荐
- No space left on device(总结)
..1 提示磁盘满了 df -hT 没有满 请问可能原因 可能是inode满了,原因是机器上的小文件太多了 使用df -hi 查看 ..2 提示没有磁盘空间已经满了 ..2.1 问题描述: 发现是日志 ...
- 15. 深入解析Pod对象(二):使用进阶
15. 深入解析Pod对象(二):使用进阶 15.1 Projected Volume,投射数据卷 备注:Projected Volume 是 Kubernetes v1.11 之后的新特性 在 Ku ...
- python下matplotlib的subplot的多图显示位置的问题
1.说明 1.1 多图: 221,222 212 ------------附最后讲解,这下更清楚了吧,取个名字:颠倒一下--- 1.2 多图 211 223,224 ------------附最后讲解 ...
- 树莓派Raspberry实践笔记—显示分辨率配置
转载:http://www.cnblogs.com/atsats/p/6607886.html 如果未接显示设备,使用VNC登录后,显示分辨率很小,应该是480p,导致使用很不方便. 这里通过修改/b ...
- VUE组件 单独文件封装
https://www.cnblogs.com/SamWeb/p/6391373.html vuejs 单文件组件.vue 文件 vuejs 自定义了一种.vue文件,可以把html, css, ...
- [02]Sort选择排序
选择排序 算法速度:通过大O表示法表示,O(n),n是操作数,表示算法执行的次数: 数组:是有序的元素序列:若将有限个类型相同的变量的集合命名,那么这个名称为数组名: 链表:是一种物理存储单元上非连续 ...
- 华水开学第一课&微信支付
由于疫情的延续,导致我们不能及时开学.只能在网上观看华水开学第一课,但是好像正常开学也没有这个哈哈(不记得了) 昨天没有玩到很晚,12点就睡下.大约半个小时睡着了.定了8点的闹钟.起来的时候那是真的困 ...
- 于elasticsearch-rest-high-level-client 操作 Es
安装Java:要求JDK为1.8及以上版本. 创建阿里云Elasticsearch实例:实例版本要求大于等于elasticsearch-rest-high-level-client的版本.本文创建一个 ...
- TCP通讯代码
服务端代码: import socket server_socket=socket.socket(socket.AF_INET,socket.SOCK_STREAM) # 使用固定端口 server_ ...
- java.util.ConcurrentModificationException 异常原因和解决方法
不要在 foreach 循环里进行元素的 remove/add 操作.remove 元素请使用 Iterator方式,如果并发操作,需要对 Iterator 对象加锁. 注意: 1.foreach遍历 ...