Linux - Server This forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a
virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month.
Click here for more info.
12-07-2008, 05:04 AM
#1
Senior Member
Registered: Apr 2003
Posts: 3,695
Rep:
Question on MySQL
Hi folks,
mysql version
Ver 14.12 Distrib 5.0.32
I ran following command creating a table:-
Code:
mysql> CREATE TABLE `tblPerdition` (
-> `user` varchar(128),
-> `servername` varchar(255) default '',
-> `port` varchar(8) NULL default 'NULL',
-> PRIMARY KEY (`user`)
-> );
Query OK, 0 rows affected (0.00 sec)
Code:
mysql> DESCRIBE tblPerdition;
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| user | varchar(128) | NO | PRI | | |
| servername | varchar(255) | YES | | | |
| port | varchar(8) | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
I can't figure out how to made Null columns of 'user' blank (without NO)
and 'servername' blank (without YES)
Please help. TIA
B.R.
satimis
Last edited by satimis; 12-07-2008 at 05:09 AM .
12-07-2008, 06:34 AM
#2
Member
Registered: Dec 2002
Location: In front of a computer
Distribution: UPS, DHL, FedEx
Posts: 466
Rep:
You can't make the primary key null cause then only one row would be allowed to be null(primary keys are unique)
Try this...
CREATE TABLE `tblPerdition` (
`user` varchar(128),
`servername` varchar(255) not null,
`port` varchar(8) NULL default 'NULL',
);
12-07-2008, 06:49 AM
#3
Senior Member
Registered: Apr 2003
Posts: 3,695
Original Poster
Rep:
Quote:
Originally Posted by
niknah
You can't make the primary key null cause then only one row would be allowed to be null(primary keys are unique)
Try this...
CREATE TABLE `tblPerdition` (
`user` varchar(128),
`servername` varchar(255) not null,
`port` varchar(8) NULL default 'NULL',
);
Hi niknah,
Thanks for your advice.
Tried unable to work for me;
Code:
mysql> CREATE TABLE `tblPerdition` (
-> `user` varchar(128),
-> `servername` varchar(255) not null,
-> `port` varchar(8) NULL default 'NULL',
-> PRIMARY KEY (`user`)
-> );
Query OK, 0 rows affected (0.07 sec)
Code:
mysql> DESCRIBE tblPerdition;
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| user | varchar(128) | NO | PRI | | |
| servername | varchar(255) | NO | | | |
| port | varchar(8) | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
3 rows in set (0.02 sec)
If putting on the 3rd line;
Code:
`servername` varchar(255) null '' default '',
It complained syntax incorrect.
Edit:
On Null field does it only have "NOT NULL" and "NULL"?
I'm following MySQL on following thread;
http://www.vergenet.net/linux/perdit...tiondb.5.shtml
to setup this table.
B.R.
satimis
Last edited by satimis; 12-07-2008 at 07:14 AM .
12-07-2008, 05:52 PM
#4
Member
Registered: Dec 2002
Location: In front of a computer
Distribution: UPS, DHL, FedEx
Posts: 466
Rep:
Quote:
If putting on the 3rd line;
Code:
`servername` varchar(255) null '' default '',
It complained syntax incorrect.
That was your line that you had put there?
I had removed the primary key too.
To make the perdition table use...
CREATE TABLE `tblPerdition` (
`user` varchar(128) primary key,
`servername` varchar(255) not null,
`port` varchar(8)
);
12-07-2008, 06:49 PM
#5
Senior Member
Registered: Apr 2003
Posts: 3,695
Original Poster
Rep:
Quote:
Originally Posted by
niknah
That was your line that you had put there?
I had removed the primary key too.
To make the perdition table use...
CREATE TABLE `tblPerdition` (
`user` varchar(128) primary key,
`servername` varchar(255) not null,
`port` varchar(8)
);
Hi niknah,
Code:
mysql> CREATE TABLE `tblPerdition` (
-> `user` varchar(128) primary key,
-> `servername` varchar(255) not null,
-> `port` varchar(8)
-> );
Query OK, 0 rows affected (0.00 sec)
Code:
mysql> DESCRIBE tblPerdition;
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| user | varchar(128) | NO | PRI | | |
| servername | varchar(255) | NO | | | |
| port | varchar(8) | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
I got it. Thanks.
The table on that URL gave me a wrong concept looking for solution to make "Null" blank.
B.R.
satimis
All times are GMT -5. The time now is 12:08 PM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News