25. maj 2000 - 09:24Der er
5 kommentarer og 1 løsning
SQL: Tekstfelter med Unicode-komprimering og nul-længde
Hvordan opretter jeg en tabel med Unicode-komprimerede tekstfelter hvor strenge af længden nul er tilladte? Hvis jeg opretter en tabel på følgende måde:
CREATE TABLE MineTing (EnTing CHAR(50))
Hvordan gør jeg så, sådan at EnTing er Unicode-komprimeret og den kan indeholde strenge af længden nul?
Create Table MineTing (EnTing NVarChar(50) NULL) hvor N angiver unicode, var betyder at længden skal være variabel og NULL betyder tillad NULL værdier. Den variable værdi optager altså max 50 tegn men måske mindre.
Bemærk at unicode kun virker ved SQL 7 Jeg er ikke sikker på access og andre databaser.
Hilsen Soni
PS: Hvis dette ikke hjælper, så angiv lige til hvilken database dette skal bruges...
Øv øv! Det virker ikke med Access 2000! Jeg har også lige testet hos Infopaq.dk hvor den færdige ASP side skal ligge, der virker det heller ikke! Feltet bliver ikke unicode komprimeret, og NULL værdier tillades ikke. I Access mener jeg også NULL betyder, at feltet ikke er obligatorisk. Hvis man skriver NOT NULL i sin CREATE TABLE sker der i hvert fald det, at feltet bliver obligatorisk.
Tak for hjælpen. Jeg bliver desværre nødt til at afvise dit svar.
Det er rigtigt at NULL betyder at feltet ikke er obligatorisk. Det er det som tillad NULL betyder, da du ikke kan indsætte NULL, men du kan lade feltet være tomt. Hvis det ikke må være tomt, indsæt en default værdi.
CREATE [TEMPORARY] TABLE table (field1 type [(size)] [NOT NULL] [WITH COMPRESSION | WITH COMP] [index1] [, field2 type [(size)] [NOT NULL] [index2] [, ...]] [, CONSTRAINT multifieldindex [, ...]])
The CREATE TABLE statement has these parts:
Part Description table The name of the table to be created. field1, field2 The name of field or fields to be created in the new table. You must create at least one field. type The data type of field in the new table. size The field size in characters (Text and Binary fields only). index1, index2 A CONSTRAINT clause defining a single-field index. For more information on how to create this index, see CONSTRAINT Clause. multifieldindex A CONSTRAINT clause defining a multiple-field index. For more information on how to create this index, see CONSTRAINT Clause.
Remarks Use the CREATE TABLE statement to define a new table and its fields and field constraints. If NOT NULL is specified for a field, then new records are required to have valid data in that field.
A CONSTRAINT clause establishes various restrictions on a field, and can be used to establish the primary key. You can also use the CREATE INDEX statement to create a primary key or additional indexes on existing tables.
You can use NOT NULL on a single field or within a named CONSTRAINT clause that applies to either a single field or to a multiple-field named CONSTRAINT. However, you can apply the NOT NULL restriction only once to a field. Attempting to apply this restriction more than once results in a run-time error.
When a TEMPORARY table is created it is visible only within the session in which it was created. It is automatically deleted when the session is terminated. Temporary tables can be accessed by more than one user.
The WITH COMPRESSION attribute can be used only with the CHARACTER and MEMO (also known as TEXT) data types and their synonyms.
The WITH COMPRESSION attribute was added for CHARACTER columns because of the change to the Unicode character representation format. Unicode characters uniformly require two bytes for each character. For existing Microsoft® Jet databases that contain predominately character data, this could mean that the database file would nearly double in size when converted to the Microsoft Jet version 4.0 format. However, Unicode representation of many character sets, those formerly denoted as Single-Byte Character Sets (SBCS) can easily be compressed to a single byte. If you define a CHARACTER column with this attribute, data will automatically be compressed as it is stored and uncompressed when retrieved from the column.
Mange tak for hjælpen. Det var lige det jeg skulle bruge.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.