SQL Server中:
select name from syscolumns where id = object_id('A') and colid = 5;

解决方案 »

  1.   

    select name from syscolumns where colid = 5 and id = object_id('myTable')
      

  2.   

    oralce:
    select  COLUMN_NAME from 
    (select COLUMN_NAME,rownum r from  all_tab_columns where TABLE_NAME=yourtable) a
    where a.r=5;
      

  3.   

    To: xzou(缺齿小狼), using column_id instead of rownum, otherwise the result will be wrong.select column_name
     from  all_tab_columns
    where table_name = myTable
      and column_id  = 5:)
      

  4.   

    to KingSunSha(弱水三千) 
    对的,你的更好,不过我的也没什么错误呀
      

  5.   

    To: xzou(缺齿小狼), 在我这边运行就有错误, 选出的并不是第5个字段. 而且从逻辑上来讲, ROWNUM在不带任何排序的情况下一般是以物理存储位置的前后排列的, 和字段排在表中的第几个位置无关.
      

  6.   

    to KingSunSha(弱水三千) :
    多谢指教,我觉得自己的方法也很差,不过没想到有错误,能不能找到一个测试这个错误的方法?也就是想办法产生出来这样一个错误.
          
      

  7.   

    TO: 你可以试试生成几个不同字段数的表,然后DROP掉一部分, 然后在建立几个表... 多搞几次,相信后面生成的表就导致这种错误的发生.
    其实, ALL_TAB_COLUMNS也是也表, CREATE TABLE/ALTER TABLE/DROP TABLE就相当于在这个系统表中进行DML操作, 多次DML操作肯定会导致不连续存储.