Seite 1 von 1

PostgreSQL Field Name "Laenge" ? [erledigt]

Verfasst: So, 29. Jul 2012 5:23
von AUGE_OHR
hi,

ich wollt mein "ModiStru" Modul für PostgreSQL Fields verwenden und hab ein "Problem"
Pg_DbStructur.PNG
Pg_DbStructur.PNG (36.56 KiB) 10284 mal betrachtet
hat jemand schon ein "fertiges" Modul für "Longname" ?

Frage : wie lang darf den ein Field Name unter PostgreSQL sein ?

p.s. hat eine "Integer" wirklich Len = 19 ?

Re: PostgreSQL Field Name "Laenge" ?

Verfasst: So, 29. Jul 2012 15:51
von UliTs
Hallo Jimmy,

zum P.S. kann ich etwas sagen:
ich vermute, Du verwechselst "Integer" und "Numeric".
Das PGu-Programm (gehört dies zum PostGreeSQL-Server?) zeigt bei den letzten 3 Feldern N,19 an.
Also wird es sich um numerische Felder handeln :-) .

Uli^

Re: PostgreSQL Field Name "Laenge" ?

Verfasst: Mo, 30. Jul 2012 4:30
von AUGE_OHR
UliTs hat geschrieben:ich vermute, Du verwechselst "Integer" und "Numeric".

Das PGu-Programm (gehört dies zum PostGreeSQL-Server?) zeigt bei den letzten 3 Feldern N,19 an.
Also wird es sich um numerische Felder handeln :-) .
da ich der Autor von PGu bin hab natürlich ich den Mist gebaut.

ich hab ja mein DBF Modul genommen und wollte damit für PostgreSQL Field ein "MODI STRU" bauen.
nun hatte ich "nur" bemerkt das "COPY STRUCTURE EXTENDED" aber die Feldname auf 10 Zeichen kürzt und deshalb die Frage nach der "Länge" eines Field Namen.

wie du richtig bemerkst... das sind "Integer" und keine "Numeric" was DbCopyExtStruct() nicht "verstand".
so ist es nun "richtig"
Integer_32.PNG
Integer_32.PNG (12.64 KiB) 10260 mal betrachtet

Re: PostgreSQL Field Name "Laenge" ?

Verfasst: Mo, 30. Jul 2012 8:06
von brandelh
Eine LONG (Standardinteger bei 32 bit Systemen) benötigt aber nur 4 Byte zur Speicherung (32 bit) ;-)
Die maximale Anzeigelänge ohne Vorzeichen sind 10 Stellen, also müsste es bei einer DBF 11 sein (−2.147.483.648 bis 2.147.483.647)

Re: PostgreSQL Field Name "Laenge" ?

Verfasst: Mo, 30. Jul 2012 19:50
von AUGE_OHR
hi,

wir (Edgar und ich) ermitteln die PgSQL:DbStruc() so

Code: Alles auswählen

::exec( "SELECT column_name, data_type, character_maximum_length, numeric_precision,numeric_scale " + ;
        "FROM information_schema.columns WHERE table_name='" + cTable + "'" )

oStruct := ::result
... aber ich weiss immer noch nicht wie lang ein Fieldname maximal sein darf ???

Re: PostgreSQL Field Name "Laenge" ?

Verfasst: Di, 31. Jul 2012 8:49
von brandelh
Geh doch in den Admin und erstelle Felder mit immer längeren Namen bis es kracht ;-)

Re: PostgreSQL Field Name "Laenge" ?

Verfasst: Di, 31. Jul 2012 9:36
von georg
Hallo, Hubert -


so sehr ich Deinen Vorschlag kenne (und oft auch selbst befolge), PostgreSQL ist da sehr geheim:
4.1.1. Identifiers and Key Words

Tokens such as SELECT, UPDATE, or VALUES in the example above are examples of key words, that is, words that have a fixed meaning in the SQL language. The tokens MY_TABLE and A are examples of identifiers. They identify names of tables, columns, or other database objects, depending on the command they are used in. Therefore they are sometimes simply called "names". Key words and identifiers have the same lexical structure, meaning that one cannot know whether a token is an identifier or a key word without knowing the language. A complete list of key words can be found in Appendix C.

SQL identifiers and key words must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_). Subsequent characters in an identifier or key word can be letters, underscores, digits (0-9), or dollar signs ($). Note that dollar signs are not allowed in identifiers according to the letter of the SQL standard, so their use might render applications less portable. The SQL standard will not define a key word that contains digits or starts or ends with an underscore, so identifiers of this form are safe against possible conflict with future extensions of the standard.

The system uses no more than NAMEDATALEN-1 bytes of an identifier; longer names can be written in commands, but they will be truncated. By default, NAMEDATALEN is 64 so the maximum identifier length is 63 bytes. If this limit is problematic, it can be raised by changing the NAMEDATALEN constant in src/include/pg_config_manual.h.
(Hervorhebungen von mir.)

Quelle: http://www.postgresql.org/docs/9.1/stat ... DENTIFIERS

Zu dem Zitat gehört auch noch dieser Hinweis:
Legal Notice

PostgreSQL is Copyright © 1996-2011 by the PostgreSQL Global Development Group and is distributed under the terms of the license of the University of California below.

Postgres95 is Copyright © 1994-5 by the Regents of the University of California.

Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.

IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS-IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
In der Version 9.1 sind 63 Stellen signifikant, d.h. das System akzeptiert auch längere Namen, verwendet intern aber nur die ersten 63 Stellen.

Warum kommt keiner auf die Frage, mal in die Dokumentation zu schauen? :coffee:


Gruss,

Georg

Re: PostgreSQL Field Name "Laenge" ?

Verfasst: Di, 31. Jul 2012 9:40
von brandelh
georg hat geschrieben:Warum kommt keiner auf die Frage, mal in die Dokumentation zu schauen? :coffee:
Weil es keine Frage sondern eine Lösung ist ;-) wahrscheinlich einfach zu einfach :D

Re: PostgreSQL Field Name "Laenge" ?

Verfasst: Di, 31. Jul 2012 10:01
von georg
Tja,


die "Frage" sollte eigentlich eine "Idee" sein, wahrscheinlich brauche ich jetzt erst mal einen Kaffee.


Gruss,

Georg

Re: PostgreSQL Field Name "Laenge" ?

Verfasst: Di, 31. Jul 2012 21:56
von AUGE_OHR
georg hat geschrieben:In der Version 9.1 sind 63 Stellen signifikant, d.h. das System akzeptiert auch längere Namen, verwendet intern aber nur die ersten 63 Stellen.
aha, DANKE !!!
georg hat geschrieben:Warum kommt keiner auf die Frage, mal in die Dokumentation zu schauen? :coffee:
nun es ist wirklich nicht so das ich mich nicht "bemüht" hätte aber mir fehlte der "Suchbegriff"

ok dann kann ich wohl auch diesen Thread als [erledigt] markieren

Re: PostgreSQL Field Name "Laenge" ? [erledigt]

Verfasst: Mi, 01. Aug 2012 5:14
von georg
Guten Morgen, Jimmy -


der Suchbegriff fehlte mir auch, daher habe ich beim CREATE TABLE angesetzt, denn dort musste sich ja ein Hinweis auf die zulässigen Namen für Felder finden lassen.


Gruss,

Georg