1. Tom Levesque Guest

## Question about data types(integer problems)

I&#039m still having problems with my create table statement. What is the max value an INTEGER can hold? And I thought you could do LONG INTEGER as you could LONG TEXT to allow for a larger number of bits to be stored... but LONG INTEGER produces an error in SQL, please give me a hand creating this table. I want my primary key column to be integer and be able to hold large numbers (ie there will be a lot of rows and each one will obviously have a unique integer id because its the primary key..)

2. Senior Member
Join Date
Dec 1969
Posts
733

## RE: Question about data types(integer problems)

The max value for an int is 32757 (or something close to that; double that if it&#039s unsigned). I don&#039t remember the limit for a long, but you&#039re not likely to exceed it.

3. Tom Levesque Guest

## OK More questions, derek, garth, Bill, someone :)

Here are my current tables(well, the statements that created them):<BR><BR>I&#039ve created all of these one by one and it&#039s all working. The ONLY thing that doesn&#039t seem to work are the two tables with the FOREIGN KEYS in them. I&#039d appreciate any suggestions as to how I have this setup and mostly I&#039d like to know what I&#039m doing wrong with the two tables that have foreign keys...<BR><BR>sql = "CREATE TABLE regusers ( id int primary key, "<BR>sql = sql & "firstname varchar, lastname varchar, "<BR>sql = sql & "email varchar, age int, gender varchar(1), "<BR>sql = sql & "callsign varchar, password varchar, "<BR>sql = sql & "numberOfPosts int, status varchar, dateOfCreation datetime );"<BR> <BR>conn.Execute(sql)<BR><BR>sql = "CREATE TABLE threads ( id int primary key, "<BR>sql = sql & "topicTitle varchar, postDate datetime, " <BR>sql = sql & "posterId int FOREIGN KEY REFERENCES regusers(id), "<BR>sql = sql & "sectionNum int FOREIGN KEY REFERENCES sections(id) );"<BR> <BR>conn.Execute(sql)<BR><BR>sql = "CREATE TABLE replies ( id int primary key, "<BR>sql = sql & "threadnum id FOREIGN KEY REFERENCES threads(id), "<BR>sql = sql & "title varchar not null, postDate datetime, "<BR>sql = sql & "content long text not null);"<BR> <BR>conn.Execute(sql)<BR> <BR>sql = "CREATE TABLE sections ( id int primary key, "<BR>sql = sql & "sectionName varchar, sectionType varchar);"<BR> <BR>conn.Execute(sql)

4. Garth Guest

## RE: OK More questions, derek, garth, Bill, someone

Threads doesn&#039t work because you reference Sections, which has yet to be created. Replies doesn&#039t work because it references Threads, and Threads doesn&#039t exist because of the previous sentence. A table must exist before you can reference it with a foreign key constraint. If you create Sections first everything should work.<BR><BR>Garth<BR>www.SQLBook.com<BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•