return to tranceaddict TranceAddict Forums Archive > Main Forums > Chill Out Room

 
SQL help
View this Thread in Original format
UglyDave
folks, i'm using some gay web interface to create database tables.

code:
CREATE TABLE `tstBB_thread` ( `thread_id` INT NOT NULL , `thread_starter` VARCHAR NOT NULL , `partOf_forum` INT NOT NULL , PRIMARY KEY ( `thread_id` ) )


that code is generated..

this is the error i get:

You have an error in your SQL syntax near 'NOT NULL, `partOf_forum` INT NOT NULL, PRIMARY KEY (`thread_id`))' at line 1


anyone?

David
reveal
What happens if you write like this?

code:
CREATE TABLE `tstBB_thread` ( `thread_id` INT NOT NULL primary key, `thread_starter` VARCHAR NOT NULL , `partOf_forum` INT NOT NULL )
UglyDave
quote:
Originally posted by reveal
What happens if you write like this?

code:
CREATE TABLE `tstBB_thread` ( `thread_id` INT NOT NULL primary key, `thread_starter` VARCHAR NOT NULL , `partOf_forum` INT NOT NULL )


that's how i would have done it if i were writing it myself..

i tried your example and got the following error:

"You have an error in your SQL syntax near 'NOT NULL , `partOf_forum` INT NOT NULL )' at line 1"

whih the bloody error messages wern't so vague..

thanks for the help all the same!

Dave
DigiNut
quote:
Originally posted by UglyDave
that's how i would have done it if i were writing it myself..

i tried your example and got the following error:

"You have an error in your SQL syntax near 'NOT NULL , `partOf_forum` INT NOT NULL )' at line 1"

whih the bloody error messages wern't so vague..

thanks for the help all the same!

Dave

A primary key by definition can't have null values, so that's redundant.

Take away the "not null" for the primary key and just leave the "primary key" keywords.

i.e. just thread_id int primary key.
UglyDave
quote:
Originally posted by DigiNut
A primary key by definition can't have null values, so that's redundant.

Take away the "not null" for the primary key and just leave the "primary key" keywords.

i.e. just thread_id int primary key.


just tried:

code:
CREATE TABLE 'tstBB_thread' ( 'thread_id' integer(2) PRIMARY KEY, 'thread_starter' varcher(15), 'partOf_forum' integer(2));


pile of crap!
UglyDave
and there i was thinking "yay!! here's DigiNut to the rescue.."
DigiNut
quote:
Originally posted by UglyDave
just tried:

code:
CREATE TABLE 'tstBB_thread' ( 'thread_id' integer(2) PRIMARY KEY, 'thread_starter' varcher(15), 'partOf_forum' integer(2));


pile of crap!

What version of SQL are you writing this for? The syntax looks totally alien to me, here's what it would look like for MSSQL:

code:
CREATE TABLE tstBB_thread { thread_id int primary key, thread_starter varchar(15), partOf_forum int }


But yours may work differently. Try your last code, but take out the integer(2) and replace them with just int, and spell varchar right. :p

Edit: should be acceptable to add "not null" before the comma on the LAST TWO declarations (starter and partof).
UglyDave
the thing that's pissin me off the most, is that there's an interface for creating tables and all that, all u do is enter the amount of rows and the table name.

then it asks u for the individual values.

it's very very annoyin.

i'm about to giv up. drink my can of guinness then off to bed.

David
DigiNut
quote:
Originally posted by UglyDave
the thing that's pissin me off the most, is that there's an interface for creating tables and all that, all u do is enter the amount of rows and the table name.

then it asks u for the individual values.

it's very very annoyin.

i'm about to giv up. drink my can of guinness then off to bed.

David

Did you try what I just said? What was the result?

You should also be able to generate the tables with that utility, and generate a TSQL script for it within the same utility.
UglyDave
tried your example, but no joy.

i set up a phpBB a few months ago on the same database, so i've just retrieved some code from it, so i'm gonna try it's syntax.

another thing that's possible..

with digitalspace.net (my hosting crew), u get 1 free database, then the rest u have to pay for..

i have 30 tables in this one.. and i'm thinkin that maybe there's a restriction on the amount of tables / database..

about to try:

code:
CREATE TABLE phpbb_config ( config_name varchar(255) NOT NULL, config_value varchar(255) NOT NULL, PRIMARY KEY(config_name));


AND IT IN WORKED!!

:)
CLICK TO RETURN TO TOP OF PAGE
 
Privacy Statement