お知らせ

電子会議

ライブラリ

パレット

Delphi FAQ検索

Delphi FAQ一覧

サンプル蔵





FDelphi FAQ
16番会議室「玉石混淆みんなで作るSample蔵」に寄せられたサンプル

"RE:テーブルの項目の一覧を得る"

この発言は
#01050 凛 さんのテーブルの項目の一覧を得る
に対するコメントです

---> 凛さんこんにちは、丁度私も同じようなのを作った所です 違うのは SQLの CREATE文形式で表示する事です。 なお、私が使った事ない項目名は、適当に表示していますのであしからず。 //DCC32 -CC DBFLDN.PAS で作成 // コンソール窓からデータベースエリアスを引数にして渡す program DBFLDN; uses SysUtils,Classes,db,DBTables; var s:TStringList; x:integer; i,j:integer; begin if ParamCount <1 then begin writeln(' データベース名(エリアス)を渡します');exit; end; s:=TStringList.create; try Session.GetTableNames(ParamStr(1),'*',true,false,s); for i:=0 to s.count -1 do with TTable.Create(nil) do try DatabaseName:= ParamStr(1); TableName:=s.Strings[i]; open; writeln('CREATE TABLE "',s.Strings[i],'"'); writeln('('); for j:=0 to FieldCount -1 do with Fields[j] do begin if j=0 then write( ' ') else write( ','); x:=8-length(fieldName);if x<0 then x:=0; write( format('/*%2d*/ %s%*s',[FieldNo,FieldName,x,'']),' '); case DataType of ftBCD:write(format('DECIMAL(x,y)',[size])); ftBlob:write(format('BLOB(%d,2)',[size])); ftBoolean:write('BOOLEAN'); ftBytes:write(format('BYTES(%d)',[size])); ftCurrency:write('MONEY'); ftDataSet:write(format('データセット項目',[size])); ftDate:write('DATE'); ftDateTime:write(format('TIMESTAMP',[size])); ftDBaseOle:write(format('dBASE OLE 項目',[size])); ftFixedChar:write(format('固定長文字型項目',[size])); ftFloat:write(format('FLOAT(x,y)',[size])); ftFmtMemo:write(format('BLOB(n,3)',[size])); ftGraphic:write(format('BLOB(n,5)',[size])); ftInteger:write('INTEGER'); ftLargeInt:write(format('32 ビット整数項目',[size])); ftMemo:write(format('BLOB(n,1)',[size])); ftParadoxOle:write(format('Paradox OLE 項目',[size])); ftReference:write(format('参照項目',[size])); ftSmallint:write('SMALLINT'); ftString:write(format('CHAR(%d)',[size])); ftTime:write('TIME'); ftTypedBinary:write(format('型付きバイナリ項目',[size])); ftVarBytes:write(format('可変長バイト型項目(バイナリ格納)',[size])); ftWideString:write(format('ワイド文字項目',[size])); ftWord:write(format('16 ビット符号なし整数項目',[size])); ftUnknown:write(format('未知または未定',[size])); end; writeln; end; if IndexFieldCount >0 then begin write(', PRIMARY KEY ('); write( IndexFields[0].FieldName); if IndexFieldCount >1 then for j:=1 to indexFieldCount -1 do write(','+IndexFields[j].FieldName); writeln(')'); end; writeln(');'); close; finally free; end; finally s.free; end; end. Original document by 裏目小僧 氏 ID:(GGA03463)



ここにあるドキュメントは NIFTY SERVEの Delphi Users' Forum の16番会議室「玉石混淆みんなで作るSample蔵」に投稿されたサンプルです。これらのサンプルはボーランド株式会社がサポートする公式のものではありません。また、必ずしも動作が検証されているものではありません。これらのサンプルを使用したことに起因するいかなる損害も投稿者、およびフォーラムスタッフはその責めを負いません。使用者のリスクの範疇でご使用下さい。

Copyright 1996-2002 Delphi Users' Forum