09-12
16
用sql查看表结构
作者:Java伴侣 日期:2009-12-16
1.oracle
sql = "Select column_name, data_type, data_length, nullable";
sql += " FROM user_tab_columns ";
sql += " where table_name='";
sql += $tableName;
sql += "'";
2.sql server
sql = "select name,xtype,length,isnullable from syscolumns where id =";
sql += " (select top 1 Id from sysobjects where name = '";
sql += $tableName;
sql += "')";
3.my sql
sql = "show columns from ";
sql += $tableName;
或
sql = "desc ";
sql += $tableName;
或
sql = "describe ";
sql += $tableName;
sql = "Select column_name, data_type, data_length, nullable";
sql += " FROM user_tab_columns ";
sql += " where table_name='";
sql += $tableName;
sql += "'";
2.sql server
sql = "select name,xtype,length,isnullable from syscolumns where id =";
sql += " (select top 1 Id from sysobjects where name = '";
sql += $tableName;
sql += "')";
3.my sql
sql = "show columns from ";
sql += $tableName;
或
sql = "desc ";
sql += $tableName;
或
sql = "describe ";
sql += $tableName;
评论: 0 | 引用: 0 | 查看次数: 281
发表评论