SitePoint Sponsor |
|
User Tag List
Results 1 to 11 of 11
Thread: MySql: Creating Tables
-
Oct 13, 2001, 09:33 #1
- Join Date
- Sep 2001
- Location
- Missouri [U.S.]
- Posts
- 135
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
MySql: Creating Tables
how do i create a table for mysql db
without using SSH
or Phpmyadmin?jmulder[THE MENTOR]'s nice guy online!
Rig: AMD Athlon 800mhz; 384mb SDRam; 32mb nVidia @ 1024x768; ie 6; Windows ME; 15 gig; Cd-RW
-
Oct 13, 2001, 10:31 #2
- Join Date
- Sep 2001
- Location
- Missouri [U.S.]
- Posts
- 135
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
anyone?
jmulder[THE MENTOR]'s nice guy online!
Rig: AMD Athlon 800mhz; 384mb SDRam; 32mb nVidia @ 1024x768; ie 6; Windows ME; 15 gig; Cd-RW
-
Oct 13, 2001, 11:51 #3
- Join Date
- Apr 2001
- Location
- My Computer
- Posts
- 2,808
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
you can do it with a php script.
something like:PHP Code:$create_sql = "CREATE TABLE users (user_id INT (4) not null , username VARCHAR (32) not null , email VARCHAR (32) , PRIMARY KEY (user_id), UNIQUE (user_id))";
if(!$create_sql)
{
echo mysql_error();
exit;
}
user_id which is a number, 4 characters long, not null (null means empty)
username which is a character field, 32 char. long, not null
and email which is a character field, 32 long, and can be null.
PRIMARY KEY makes the field in the () the primary key of the table, and UNIQUE specifies a field that can't be duplicated.
If for some reason the query fails it'll echo out the mysql error that cased the failure.
-
Oct 13, 2001, 12:09 #4
- Join Date
- Apr 2001
- Location
- My Computer
- Posts
- 2,808
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
also, here's mysql's support page for create table:
http://www.mysql.com/doc/C/R/CREATE_TABLE.html
-
Oct 13, 2001, 22:54 #5
- Join Date
- Sep 2001
- Location
- Missouri [U.S.]
- Posts
- 135
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Error
SQL-query : [Edit]
CREATE TABLE `users` (`user_id` INT(4) NOT NULL, `user_name` TEXT(32) NOT NULL, `email` TEXT(32) , PRIMARY KEY (`user_id`), UNIQUE (`user_id`)) comment = 'Training'
MySQL said:
You have an error in your SQL syntax near '(32) NOT NULL, `email` TEXT(32) , PRIMARY KEY (`user_id`), UNIQUE (`user_id`)) c' at line 1jmulder[THE MENTOR]'s nice guy online!
Rig: AMD Athlon 800mhz; 384mb SDRam; 32mb nVidia @ 1024x768; ie 6; Windows ME; 15 gig; Cd-RW
-
Oct 14, 2001, 00:56 #6
- Join Date
- Apr 2001
- Location
- My Computer
- Posts
- 2,808
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
i'm not expert on the exact syntax, but why are you using the accent marks (`) around the field names?
I've created many tables fine w/o the use of them.
also, try moving the comment into the parentheses and see if that helps.
-
Oct 14, 2001, 06:55 #7Originally posted by Defender1
i'm not expert on the exact syntax, but why are you using the accent marks (`) around the field names?
SeanHarry Potter
-- You lived inside my world so softly
-- Protected only by the kindness of your nature
-
Oct 14, 2001, 15:38 #8
- Join Date
- Apr 2001
- Location
- My Computer
- Posts
- 2,808
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
heh, if he's using phpmyadmin, why does he want the code to do it?
-
Oct 14, 2001, 19:15 #9
- Join Date
- Sep 2001
- Location
- Missouri [U.S.]
- Posts
- 135
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
i tried it myself, but i had no results....so i gave it a go in the admin thing......it works now
but i want to learn MySql without the use of the adminjmulder[THE MENTOR]'s nice guy online!
Rig: AMD Athlon 800mhz; 384mb SDRam; 32mb nVidia @ 1024x768; ie 6; Windows ME; 15 gig; Cd-RW
-
Oct 14, 2001, 19:18 #10
- Join Date
- Sep 2001
- Location
- Missouri [U.S.]
- Posts
- 135
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
also....
when i look at tut's it tells me to use a secure shell program.....which i don't want to do...jmulder[THE MENTOR]'s nice guy online!
Rig: AMD Athlon 800mhz; 384mb SDRam; 32mb nVidia @ 1024x768; ie 6; Windows ME; 15 gig; Cd-RW
-
Oct 14, 2001, 23:29 #11
- Join Date
- Dec 2000
- Location
- The flat edge of the world
- Posts
- 838
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You get an error if you make column names with quotes around them, dispite what phpMyAdmin shows you.
Bookmarks