Jump to content
The mkiv Supra Owners Club

SQL datatypes


Supragal

Recommended Posts

For mySql anyway...

 

CHAR( ) A fixed section from 0 to 255 characters long.

VARCHAR( ) A variable section from 0 to 255 characters long.

TINYTEXT A string with a maximum length of 255 characters.

TEXT A string with a maximum length of 65535 characters.

BLOB A string with a maximum length of 65535 characters.

MEDIUMTEXT A string with a maximum length of 16777215 characters.

MEDIUMBLOB A string with a maximum length of 16777215 characters.

LONGTEXT A string with a maximum length of 4294967295 characters.

LONGBLOB A string with a maximum length of 4294967295 characters.

 

CHAR and VARCHAR are the most widely used types. CHAR is a fixed length string and is mainly used when the data is not going to vary much in it's length. VARCHAR is a variable length string and is mainly used when the data may vary in length.

 

CHAR may be faster for the database to process considering the fields stay the same length down the column. VARCHAR may be a bit slower as it calculates each field down the column, but it saves on memory space. Which one to ultimatly use is up to you.

 

Using both a CHAR and VARCHAR option in the same table, MySQL will automatically change the CHAR into VARCHAR for compatability reasons.

 

BLOB stands for Binary Large OBject. Both TEXT and BLOB are variable length types that store large amounts of data. They are similar to a larger version of VARCHAR. These types can store a large piece of data information, but they are also processed much slower.

Link to comment
Share on other sites

blobs! :lol:

 

Can you DESC the table? That'll tell you what that text col is limited to. (If that's what you're asking?)

 

I don't know what that means :innocent:

 

But that sounds like what I am trying to find out.....

 

Homer - you scared me for a moment then :D

Link to comment
Share on other sites

In most respects, a TEXT field is just a VARCHAR with an unlimited(ish) length, I believe.

Depends what system/language you're using...but it's usually fairly limited. That's what Memo and Blobs are for.

Link to comment
Share on other sites

I don't know what that means :innocent:

 

But that sounds like what I am trying to find out.....

 

Homer - you scared me for a moment then :D

Is it Oracle SQL or what?

 

At the SQL> prompt just type

 

DESC RosiesTableName

and it'll tell you what datatype the different columns are and in brackets it'll tell you the max they can hold. (If I've understood what you're asking corrrectly)

 

Also:

http://mg264.imck.us/g264/7159

 

;)

Link to comment
Share on other sites

Ok, desc does not work in sql

 

sp_help {tableName} works

 

ItemID uniqueidentifier

Path nvarchar

Name nvarchar

ParentID uniqueidentifier

Type int

Content image

Intermediate uniqueidentifier

SnapshotDataID uniqueidentifier

LinkSourceID uniqueidentifier

Property ntext

Description nvarchar

Hidden bit

CreatedByID uniqueidentifier

CreationDate datetime

ModifiedByID uniqueidentifier

ModifiedDate datetime

MimeType nvarchar

SnapshotLimit int

Parameter ntext

PolicyID uniqueidentifier

PolicyRoot bit

ExecutionFlag int

ExecutionTime datetime

 

from sql help:

 

text

Variable-length non-Unicode data in the code page of the server and with a maximum length of 2^31-1 (2,147,483,647) characters. When the server code page uses double-byte characters, the storage is still 2,147,483,647 bytes. Depending on the character string, the storage size may be less than 2,147,483,647 bytes.

Link to comment
Share on other sites

Ok, desc does not work in sql

 

sp_help {tableName} works

 

ItemID uniqueidentifier

Path nvarchar

Name nvarchar

ParentID uniqueidentifier

Type int

Content image

Intermediate uniqueidentifier

SnapshotDataID uniqueidentifier

LinkSourceID uniqueidentifier

Property ntext

Description nvarchar

Hidden bit

CreatedByID uniqueidentifier

CreationDate datetime

ModifiedByID uniqueidentifier

ModifiedDate datetime

MimeType nvarchar

SnapshotLimit int

Parameter ntext

PolicyID uniqueidentifier

PolicyRoot bit

ExecutionFlag int

ExecutionTime datetime

 

from sql help:

 

text

Variable-length non-Unicode data in the code page of the server and with a maximum length of 2^31-1 (2,147,483,647) characters. When the server code page uses double-byte characters, the storage is still 2,147,483,647 bytes. Depending on the character string, the storage size may be less than 2,147,483,647 bytes.

 

Ok, cool, that worked, thanks. Except I am really confused now as it says 'length' '16' which means nothing to me as clearly it is more than 16... so 16 must not mean 16 literally, right?

 

But the description you gave me does the job :thumbs:

 

Cheers guys :) You should come work here lol

Link to comment
Share on other sites

IIRC - for these kind of fields, the data is not stored in the table itself. Instead, the data is stored elsewhere and the table just stores a "pointer" to the data. It is just the pointer that is of size 16. The TEXT itself will be much bigger.

Link to comment
Share on other sites

Is it Oracle SQL or what?

 

At the SQL> prompt just type

 

DESC RosiesTableName

and it'll tell you what datatype the different columns are and in brackets it'll tell you the max they can hold. (If I've understood what you're asking corrrectly)

 

Also:

http://mg264.imck.us/g264/7159

 

;)

 

IIRC - for these kind of fields, the data is not stored in the table itself. Instead, the data is stored elsewhere and the table just stores a "pointer" to the data. It is just the pointer that is of size 16. The TEXT itself will be much bigger.

 

exactly...

Link to comment
Share on other sites

IIRC - for these kind of fields, the data is not stored in the table itself. Instead, the data is stored elsewhere and the table just stores a "pointer" to the data. It is just the pointer that is of size 16. The TEXT itself will be much bigger.
Ah, gotcha. Thanks
Link to comment
Share on other sites

Ok, what kind of elsewhere? Is that location the thing that has the 2^31-1 (2,147,483,647) characters?

 

Not sure exactly elsewhere - I guess that's up to the specific database implementation - but that 2Gb size limit sounds right for a TEXT.

 

Note - I think the separate storage means that TEXT fields are a lot slower than VARCHARS for some substring queries (such as "LIKE" clauses), but I'm open to correction on that claim!

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. You might also be interested in our Guidelines, Privacy Policy and Terms of Use.