Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old February 14th, 2003, 02:58 PM
boettger boettger is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Ontario, Canada
Posts: 11 boettger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Alter table needs help

I'm trying to add a field to an existing table. I would like this field to be a foreign key to another table not yet created. When I follow the code in my book I get an error on the adding of the field. Here is what code I'm using.

mysql> ALTER TABLE joke ADD author_id AFTER joke_date;
ERROR 1064: You have an error in your SQL syntax near 'AFTER joke_date' at line
1

Thanks for any help.

Reply With Quote
  #2  
Old February 15th, 2003, 06:14 AM
brut brut is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 367 brut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Alter table needs help

You've gop the right idea, but you need to specify the column type, and any other attributes, just as you do when creating a table. Try something like this:
Code:
mysql> ALTER TABLE joke ADD author_id TINYINT NOT NULL DEFAULT 0 AFTER id;

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Alter table needs help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway