1. oracle 查看錶結構,表裡的數據
1、首先,我們打開PLsql工具連接到需要進行數據比對的ORACLE資料庫。

2. 如何獲得資料庫中表的結構
list 表名 
得到每一個表的詳細信息欄位名,欄位屬性(類型,文字長度,備注) 
describe 表名
具體的表名
3. 如何通過JDBC取得資料庫表結構信息
JDBC中有個ResultSetMetaData類就是用來獲取數據表結構信息的。
...
ResultSet rs = ....
ResultSetMetaData rsmd = rs.getMetaData();
//ResultSetMetaData中有如下方法:
getColumnCount(); 返回 ResultSet 中的列數。 
getColumnName(int); 返回列序號為 int 的列名。 
getColumnLabel(int); 返回此列暗含的標簽。 
isCurrency(int); 如果此列包含帶有貨幣單位的一個數字,則返回 true。 
isReadOnly(int); 如果此列為只讀,則返回 true。 
isAutoIncrement(int); 如果此列自動遞增,則返回 true。這類列通常為鍵,而且始終是只讀的。 
getColumnType(int); 返回此列的 SQL 數據類型。這些數據類型包括
4. 如何利用Microsoft Query查詢資料庫表結構
方法:
使用資料庫介面工具ODBC以及查詢工具Microsoft
Query讀取數衡含據庫的表結構。結果:
使用Microsoft
Query讀櫻鏈取資料庫的表結構,對於非計算機專業人員而言,清除了數據挖掘的入門障礙。結論:Microsoft
Query讀取資料庫表結構,使用簡單,功能強大,是數據挖掘的好工具。
【關鍵詞】
Microsoft
Query;
表結構
Microsoft
Query
是Microsoft
Office的一個自帶程序,用於檢索外部的數據源,其用途非常廣泛[1]。Microsoft
Query支持的外部數據源有:Microsoft
SQL
Server
OLAP
Services7.0以上、Microsoft
Access
2000以上、dBASE、Microsoft
FoxPro、Microsoft
Excel、Oracle、Paradox、SQL
Server以及文本文件資料庫。讀取其它資料庫,可安裝其專用的ODBC介面。在醫院統計工作中,經常需要自定義的查詢數據[2],這就需要對資料庫的表結構有一個全面的了解。而作為普通用戶,終端上一般只安裝了Microsoft
Office而沒有安裝資料庫開發工具。因此,Microsoft
Query就為普通用戶提供了讀取資料庫的一條捷徑。以下給出Microsoft
Query讀取資料庫表結構的方法。
1
創建ODBC
本例中,伺服器名sgcwserver,資料庫名bagl。
打開Windows控制面板/管理工具/ODBC,進入「ODBC數據源管理器」界面。進入脊攔孫「創建到SQL
SERVER的新數據源」界面,輸入數據源名稱sgcwserver_bagl,描述:病案庫數據源。伺服器:sgcwserver。
按[下一步],選擇「使用用戶輸入登錄ID和密碼的SQL
Server驗證」。錄入登錄ID及密碼。本例登錄ID為sa,密碼為空。按[下一步],選擇所需連接的資料庫bagl。按[下一步],選擇「測試數據源」,測試成功後確定。
2
從資料庫中讀取表結構
運行Microsoft
Query程序,程序位於Office安裝目錄中,如"C:\Program
Files\Microsoft
Office\Office10\MSQRY32.EXE",運行後顯示:
在菜單中選擇『文件/執行SQL』,錄入以下SQL語句:
SELECT
"表名"=case
when
a.colorder=1
then
d.name
else
''
end,
"表說明"=case
when
a.colorder=1
then
isnull(f.value,'')
else
''
end,
"欄位號"=a.colorder,"欄位名"=a.name,
5. 如何讀取出mysql中的表結構
Online DDL 工具:pt-osc
對於 MySQL Online DDL 目前主流的有三種工具:
- 原生 Online DDL; 
- pt-osc(online-schema-change), 
- gh-ost 
本文主要講解 pt-online-schema-change 的使用以及三種工具的簡單對比。
一、原理及限制
1.1 原理
1.創建一個與原表結構相同的空表,表名是_new後綴;
2. 修改步驟 1 創建的空表的表結構;耐拿
3. 在原表上頌握加三個觸發器:delete/update/insert,用於 數據過程中,昌櫻搭將原表中要執行的語句在新表中執行;
4. 將原表數據以數據塊(chunk)的形式 到新表;
5. rename 原表為 old 表,並把新表 rename 為原表名,然後刪除舊表;
6. 刪除觸發器。
6. 怎麼獲得資料庫表結構
1,在注入時初始化這兩個模板。
    /**
     * 注入數據源, 該數據源在Spring配置文件中配置
     * 在注入時初始化這兩個模板
     * @param dataSource
     * Method create author: yanwei
     * Method create dateTime: 2011-11-2 下午03:43:13
     * Method update author:
     * Method update dateTime:
     */
    @Resource
    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
        jdbcTemplate = new JdbcTemplate(dataSource);
        simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
    }
2,獲取表結構宏帶信息。
 1 /**
 2      * 獲取表結如絕判構信息
 3      * @param tableName 表名
 4      * @return
 5      * @throws Exception
 6      * Method create author: yanwei
 7      * Method create dateTime: 2011-12-21 下午01:01:17
 8      * Method update author:
 9      * Method update dateTime:
10 */
11     public List<DsClientColumnInfo> getDsTableColumnInfo(String tableName) throws DataAccessFailureException{
12         
13         ResultSet resultSet = null;
14         Connection connection = null;
15         java.util.List<DsClientColumnInfo> clientTableInfos = new ArrayList<DsClientColumnInfo>();
16         try {
17             connection = this.jdbcTemplate.getDataSource().getConnection();
18             //獲得列的信息
19             resultSet = connection.getMetaData().getColumns(null, null, tableName, null);
20             while (resultSet.next()) {
21                  //獲得欄位渣改名稱
22                  String name = resultSet.getString("COLUMN_NAME");
23                  //獲得欄位類型名稱
24                  String type = resultSet.getString("TYPE_NAME");
25                  //獲得欄位大小
26                  int size = resultSet.getInt("COLUMN_SIZE");
27                  //獲得欄位備注
28                  String remark = resultSet.getString("REMARKS");
29                  DsClientColumnInfo info = new DsClientColumnInfo(null, null, null, name, remark, size, type, "false");
30                  clientTableInfos.add(info);
31             }
32             
33             //獲得主鍵的信息
34             resultSet = connection.getMetaData().getPrimaryKeys(null, null, tableName);
35             while(resultSet.next()){
36                  String  primaryKey = resultSet.getString("COLUMN_NAME");
37                  //設置是否為主鍵
38                  for (DsClientColumnInfo dsClientColumnInfo : clientTableInfos) {
39                     if(primaryKey != null && primaryKey.equals(dsClientColumnInfo.getClientColumnCode()))
40                         dsClientColumnInfo.setIsParmaryKey("true");
41                     else 
42                         dsClientColumnInfo.setIsParmaryKey("false");
43                 }
44             }
45             
46             //獲得外鍵信息
47             resultSet = connection.getMetaData().getImportedKeys(null, null, tableName);
48             while(resultSet.next()){
49                 String  exportedKey = resultSet.getString("FKCOLUMN_NAME");
50                 //設置是否是外鍵
51                  for (DsClientColumnInfo dsClientColumnInfo : clientTableInfos) {
52                         if(exportedKey != null && exportedKey.equals(dsClientColumnInfo.getClientColumnCode()))
53                             dsClientColumnInfo.setIsImportedKey("true");
54                         else 
55                             dsClientColumnInfo.setIsImportedKey("false");
56                 }
57             }
58             
59             
60         } catch (Exception e) {
61             e.printStackTrace();
62             throw new RuntimeException("獲取欄位信息的時候失敗,請將問題反映到維護人員。" + e.getMessage(), e);
63         } finally{
64             if(resultSet != null)
65                 try {
66                     resultSet.close();
67                 } catch (SQLException e) {
68                     e.printStackTrace();
69                        throw new DataAccessFailureException("關閉結果集resultSet失敗。",e);
70                 }finally{
71                     if(connection != null)
72                         try {
73                             connection.close();
74                         } catch (SQLException e) {
75                             e.printStackTrace();
76                                throw new DataAccessFailureException("關閉連接connection失敗。",e);
77                         }
78                 }
79         }
80         
81         Set set = new HashSet();
82         set.addAll(clientTableInfos);
83         clientTableInfos.clear();
84         clientTableInfos.addAll(set);
85         return clientTableInfos;
86     }
3,獲得資料庫中所有的表。
 1 /**
 2      * 獲得資料庫中所有的表
 3      * @return
 4      * Method create author: yanwei
 5      * Method create dateTime: 2012-1-5 上午11:23:54
 6      * Method update author:
 7      * Method update dateTime:
 8      * @throws SQLException 
 9 */
10     public Map<String, String> getDatabaseTables() throws DataAccessFailureException{
11         ResultSet resultSet = null;
12         Connection connection = null;
13         Map<String, String> map = new HashMap<String, String>();
14         try {
15              String[]   types   =   {"TABLE"};    
16             connection = this.jdbcTemplate.getDataSource().getConnection();
17             String databaseName = SynXmlAnalysis.getElementValueByName(DATABASE_NAME);
18             resultSet = connection.getMetaData().getTables(null, databaseName, null, types);
19             while(resultSet.next()){
20                 String tableName = resultSet.getString("TABLE_NAME");
21                 String remark = resultSet.getString("REMARKS");
22                 map.put(tableName, remark);
23             }
24         } catch (SQLException e) {
25             e.printStackTrace();
26             throw new DataAccessFailureException(e);
27         }catch (Exception e) {
28             e.printStackTrace();
29         }finally{
30             if(resultSet != null)
31                 try {
32                     resultSet.close();
33                 } catch (SQLException e) {
34                     e.printStackTrace();
35                        throw new DataAccessFailureException("關閉結果集resultSet失敗。",e);
36                 }finally{
37                     if(connection != null)
38                         try {
39                             connection.close();
40                         } catch (SQLException e) {
41                             e.printStackTrace();
42                                throw new DataAccessFailureException("關閉連接connection失敗。",e);
43                         }
44                 }
45         
46         }
47         return map;
48     }
