Autor Beitrag
moloch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Do 01.12.05 16:07 
Hallo,
ich möchte die Eigenschaft "grösse" eines Feldes in einer Tabelle (Mssql, Mysql etc)
per SQL verändern ohne die bereits vorhandenen Einträge zu beeinflussen.
Hat da jemand einen Tip.

mfg
moloch
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Do 01.12.05 16:19 
Was meinst du mit Grösse?

Bei String-Feldern kann man afaik die Größe nach oben ändern, ohne dass es Einfluss auf die Daten hat. Ansonsten gilt, ausprobieren.

Der SQL-Befehl dafür wäre ALTER TABLE <Tabelle> Modify <Spalte> <Typ+Grösse>

_________________
Bravery calls my name in the sound of the wind in the night...
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Fr 02.12.05 14:04 
hey,
ja mit grösse meinte ich die feldlänge.
als grösse wird diese eigenschaft im mssql-enterprise manager angegeben.
ich probier dein tip mal aus.
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Fr 02.12.05 14:24 
also die syntax krieg ich noch nicht so hin.kannst du mir da ein konkretes beispiel geben?
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Fr 02.12.05 14:25 
ausblenden SQL-Anweisung
1:
ALTER TABLE Tabelle MODIFY Spalte char(30);					

_________________
Bravery calls my name in the sound of the wind in the night...
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Fr 02.12.05 14:57 
also bei meiner mssql-db geht das nicht.
er sagt falsche syntax.
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Fr 02.12.05 15:02 
Aha... hab leider keine MSSQL da, aber vielleicht hilft dir da die Doku zum Thema ALTER TABLE weiter.

Möglicherweise musst du ziwschen MODIFY und dem Spaltennamen noch COLUMN einfügen.

_________________
Bravery calls my name in the sound of the wind in the night...
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Fr 02.12.05 15:31 
das haut irgendwie nicht hin.
senidex
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

WIN XP

BeitragVerfasst: Fr 02.12.05 19:15 
Hallo, ich selber habe kein MSQL sonder ich arbeite mit Oracle. Probier aber mal diese Syntax:
ALTER TABLE table
ALTER COLUMN column_name
new_data_type ( precision , scale )

Bsp: ALTER TABLE artikel ALTER COLUMN bezeichnung char(30)
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Mo 05.12.05 12:28 
super,
danke es funktioniert.
so einfach wenn man's weiss.
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Mo 05.12.05 12:49 
gibt es dazu auch die abfrage?
also ich möchte länge des feldes nur verändern wenn es zu kurz ist.und das möchte ich vorher abfragen
senidex
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

WIN XP

BeitragVerfasst: Mi 07.12.05 17:54 
Ein kleines Bsp:
query1 ist eine TQUERY-Komponente und über Databasename mit der Datenbank verbunden

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.BitBtnGetFeldLaengeClick(Sender: TObject);
var len : real;
begin
 query1.close;
 query1.sql.clear;
 query1.sql.add('SELECT bezeichnung FROM ABTEILUNG');
 query1.open;
 len:=Query1.Fields[0].Datasize-1; 
end;


Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Do 08.12.05 08:55 
hey,
ist .datasize nicht die menge an zeichen die in dem feld drin sind. nicht aber die menge die reinpasst?
ich brauche den grenzwert der reinpasst.
senidex
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

WIN XP

BeitragVerfasst: Do 08.12.05 18:06 
Hallo,
bei Datasize liest Delphi aus, wieviel Bytes es maximal benötigt, um das
Datenbankfeld auszulesen, unabhängig davon, mit welchen Wert das Feld belegt ist.
Es beschreibt somit die Feldlänge in der DB.
Das -1 kommt davon, weil bei einem String Delphi das 1 Byte für eigene Zwecke benötigt.