sql语句如何取得数据库中表的字段信息
可能是我表述有问题,我意思是直接在数据库中用sql语句查看一个列的数据类型,我用的sqlserver2000的数据库。谢谢...
可能是我表述有问题,我意思是直接在数据库中用sql语句查看一个列的数据类型,我用的sqlserver2000的数据库。谢谢
展开
展开全部
不知道你用的编程环境是什么,不过都是相似的
Set conn1 = Server.CreateObject("ADODB.Connection")
conn1.Open "DBQ="& Server.MapPath("ntopsamp.mdb") &";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;"
Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.Open "产品",conn1,1,3
Response.Write "text<BR>"
Response.Write "ActualSize: " & rs1("名称").ActualSize & "<BR>"
Response.Write "DefinedSize: " &rs1("名称").DefinedSize & "<BR>"
Response.Write "Type: " & rs1("名称").Type & "<BR>"
Response.Write "Name: " & rs1("名称").Name & "<BR>"
Response.Write "NumericScale: " & rs1("名称").NumericScale & "<BR>"
Response.Write "Precision: " & rs1("名称").Precision & "<p>"
Set conn1 = Server.CreateObject("ADODB.Connection")
conn1.Open "DBQ="& Server.MapPath("ntopsamp.mdb") &";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;"
Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.Open "产品",conn1,1,3
Response.Write "text<BR>"
Response.Write "ActualSize: " & rs1("名称").ActualSize & "<BR>"
Response.Write "DefinedSize: " &rs1("名称").DefinedSize & "<BR>"
Response.Write "Type: " & rs1("名称").Type & "<BR>"
Response.Write "Name: " & rs1("名称").Name & "<BR>"
Response.Write "NumericScale: " & rs1("名称").NumericScale & "<BR>"
Response.Write "Precision: " & rs1("名称").Precision & "<p>"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
查看单一表table1。
select t1.name,t2.name from syscolumns t1 left join systypes t2
on t1.xtype=t2.xtype where t1.id=object_id('table1')
查看所有表。
select tablename=t1.name,columnname=t2.name,typename=t3.name from sysobjects t1
left join syscolumns t2 on t1.id=t2.id
left join systypes t3 on t2.xtype=t3.xtype
where t1.xtype='U'
select t1.name,t2.name from syscolumns t1 left join systypes t2
on t1.xtype=t2.xtype where t1.id=object_id('table1')
查看所有表。
select tablename=t1.name,columnname=t2.name,typename=t3.name from sysobjects t1
left join syscolumns t2 on t1.id=t2.id
left join systypes t3 on t2.xtype=t3.xtype
where t1.xtype='U'
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
SELECT name, type_name(xtype) AS type, length
FROM syscolumns
WHERE (id = OBJECT_ID('dbuser')) --用你的表名换一下dbuser
FROM syscolumns
WHERE (id = OBJECT_ID('dbuser')) --用你的表名换一下dbuser
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
代码如下:
using (var conn = new MySqlConnection(connStr))
{
conn.Open();
var command = new MySqlCommand("desc user", conn);
var reader = command.ExecuteReader();
while (reader.Read())
{
Console.Write(reader.GetString(0));
Console.Write(reader.GetString(1));
Console.WriteLine();
}
}
using (var conn = new MySqlConnection(connStr))
{
conn.Open();
var command = new MySqlCommand("desc user", conn);
var reader = command.ExecuteReader();
while (reader.Read())
{
Console.Write(reader.GetString(0));
Console.Write(reader.GetString(1));
Console.WriteLine();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询