獲取指定表的表結構

2021-09-02 09:27:40 字數 1642 閱讀 2104

最近公司專案中需要做乙個使用excel員工匯入的需求,在匯入過程中,需要對資料核驗,就需要獲取相應的表結構的字段型別,及其型別精度。以下為**:

private mapgetcolumninfo()  else 

if (map.get("numeric_precision") == null) else

if (map.get("numeric_scale") == null) else

columnmap.put(column.getcolname(), column);

}return columnmap;

}

public class tablecolumninfo );

}public string getcolname()

public void setcolname(string colname)

public string getcoltype()

public void setcoltype(string coltype)

public int getcollegth()

public void setcollegth(int collegth)

public string gettablename()

public void settablename(string tablename)

public boolean isnullable()

public boolean getnullable()

public void setnullable(string nullable)

public int getnumericprecision()

public void setnumericprecision(int numericprecision)

public int getnumericscale()

public void setnumericscale(int numericscale)

}

<?xml version="1.0" encoding="utf-8" ?>

col.table_schema ,

col.table_name ,

col.ordinal_position,

col.column_name ,

col.data_type ,

col.character_maximum_length,

col.numeric_precision,

col.numeric_scale,

col.is_nullable,

col.column_default ,

des.description

from information_schema.columns col

left join pg_description des on col.table_name::regclass = des.objoid and col.ordinal_position = des.objsubid

where table_schema = # and table_name = #

order by ordinal_position

針對不同的資料庫,語法不盡相同,請注意。

獲取表結構

sql server 2000 feixian sql server 2000 select 表名 case when a.colorder 1 then d.name else end 表說明 case when a.colorder 1 then isnull f.value,else end ...

獲取指定副表資訊

在phpcms模板中我們使用pc標籤的action position 來呼叫推薦位文章列表。它並不支援直接指定獲取文章內容,因為推薦位中的文章資訊會單獨記錄在乙個資料表中並且並沒有記錄文章內容字段資訊。雖然直接不行但是可以多個標籤靈活配合得到,這也是phpcms標籤的靈活之處。我先給出演示 方法1 ...

獲取ACCESS表結構

經常有朋友問怎麼得到access的表結構。public sub gettables dim rs as new adodb.recordset dim conn as adodb.connection dim ssql as string set conn currentproject.connec...