473,394 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

auto-increments

Hello all,

I am a beginner with mysql, however installation was fine no problems and I
have been trying the Consol Center trying to create new tables. I get two
errors I can't get rid of.

1. I create a table with primary key etc and several columns. When
entering data I always get in the primary key column three letters PRI and
an error message
[root@localhost:3306] ERROR 1054: Unknown column 'PRI' in 'field list'
2. I have made the primary key column auto-incremental. If I overwrite this
PRI and put e.g. 1 in the first row the next should automatically provide 2
etc. However this does not happen, I get again PRI in that column.

Could anyone please be so kind to give me a hint what I am doing wrong.

Best regards,

Olaf
Jul 20 '05 #1
4 1811
Olafur wrote:
2. I have made the primary key column auto-incremental. If I overwrite this
PRI and put e.g. 1 in the first row the next should automatically provide 2
etc. However this does not happen, I get again PRI in that column.

Could anyone please be so kind to give me a hint what I am doing wrong.


That would be a lot easier if I would know what you are doing.

Can you provide example (copy-paste) like the one I'm giving now, so
that I could see what you are trying to do.
mysql> create table mytest(
-> id int unsigned auto_increment primary key default 5,
-> name varchar(255)
-> );
Query OK, 0 rows affected (0.00 sec)

mysql> insert into mytest(name) values('Jack');
Query OK, 1 row affected (0.00 sec)

mysql> insert into mytest(name) values('Lisa');
Query OK, 1 row affected (0.00 sec)

mysql> select * from mytest;
+----+------+
| id | name |
+----+------+
| 1 | Jack |
| 2 | Lisa |
+----+------+
2 rows in set (0.00 sec)
Jul 20 '05 #2
Thanks Aggro,
I was not using the command line, but the MySQL Command Center 0.9.4 beta.
However, using the command line as you suggest and and giving the
instruction to create the table as you indicate I get the following error:

ERROR 1067: Invalid default value for 'id'

Regards,

Olafur
"Aggro" <sp**********@yahoo.com> wrote in message
news:fJ*************@read3.inet.fi...
Olafur wrote:
2. I have made the primary key column auto-incremental. If I overwrite this PRI and put e.g. 1 in the first row the next should automatically provide 2 etc. However this does not happen, I get again PRI in that column.

Could anyone please be so kind to give me a hint what I am doing wrong.


That would be a lot easier if I would know what you are doing.

Can you provide example (copy-paste) like the one I'm giving now, so
that I could see what you are trying to do.
mysql> create table mytest(
-> id int unsigned auto_increment primary key default 5,
-> name varchar(255)
-> );
Query OK, 0 rows affected (0.00 sec)

mysql> insert into mytest(name) values('Jack');
Query OK, 1 row affected (0.00 sec)

mysql> insert into mytest(name) values('Lisa');
Query OK, 1 row affected (0.00 sec)

mysql> select * from mytest;
+----+------+
| id | name |
+----+------+
| 1 | Jack |
| 2 | Lisa |
+----+------+
2 rows in set (0.00 sec)

Jul 20 '05 #3
Olafur wrote:
Thanks Aggro,
I was not using the command line, but the MySQL Command Center 0.9.4 beta.
However, using the command line as you suggest and and giving the
instruction to create the table as you indicate I get the following error:

ERROR 1067: Invalid default value for 'id'


My mistake (I propably got older version, which didn't complain about
the error I made). That should be:

create table mytest(
id int unsigned auto_increment primary key,
name varchar(255) );

I was just trying does it work if I add default 5 at the end, but that
didn't make it to start counting from 5. I remember that there was some
way to start counting from another number than 1, but don't remember how
it was.

But if you are happy with the counting starting from 1, that should be
enough for you.
Jul 20 '05 #4
Thanks Aggro,
This goes fine I get the results from the two rows fine just as you
indcated.
My problem must have something to do with the MySQL Command Center and not
with the database as such.

Regards,

Olafur
"Aggro" <sp**********@yahoo.com> wrote in message
news:O5************@read3.inet.fi...
Olafur wrote:
Thanks Aggro,
I was not using the command line, but the MySQL Command Center 0.9.4 beta. However, using the command line as you suggest and and giving the
instruction to create the table as you indicate I get the following error:
ERROR 1067: Invalid default value for 'id'


My mistake (I propably got older version, which didn't complain about
the error I made). That should be:

create table mytest(
id int unsigned auto_increment primary key,
name varchar(255) );

I was just trying does it work if I add default 5 at the end, but that
didn't make it to start counting from 5. I remember that there was some
way to start counting from another number than 1, but don't remember how
it was.

But if you are happy with the counting starting from 1, that should be
enough for you.

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Manlio Perillo | last post by:
Hi. This post follows "does python have useless destructors". I'm not an expert, so I hope what I will write is meaningfull and clear. Actually in Python there is no possibility to write code...
1
by: Glabbeek | last post by:
I'm changing the layout of my site. Instead of using tables, I will use DIVs. It's working fine, except for 1 thing: In IE6 some DIVs are not the correct width. Mozilla and Opera are showing the...
5
by: Robert Downes | last post by:
I'm using the following in a page that I'm testing in Mozilla: p.actionLinkBlock {border: 1px #000000 dashed; padding: 0.2cm; width: auto} But the dashed border is extending to the right-edge...
20
by: Vijay Kumar R. Zanvar | last post by:
Hello, Unlike register, auto keyword can not be used to declare formal parameter(s). Is there any specific reason for this? Kind regards, Vijay Kumar R. Zanvar
6
by: Alpha | last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key column and the 2nd is a string. When I add a new row to the dataset to be updated back to the database. What should I...
5
by: Samuel | last post by:
Hi, I am running into a problem of mixing UICulture = auto and allowing users to select culture using a dropdown list. I am detecting a querystring, "setlang", and when found, setting the...
5
by: maya | last post by:
at work they decided to center divs thus: body {text-align:center} #content {width: 612px; text-align:left; margin: 0 auto 0 auto; } this works fine in IE & FF, EXCEPT in FF it doesn't work if...
22
by: nospam_news | last post by:
I currently get asked about my usage of "auto". What is it for? The keyword is clearly superflous here. In contrast to the huge majority of C/C++ developers I write definitions very explicitly...
2
by: Piotr K | last post by:
Hi, I've encountered a strange problem with Firefox which I don't have any idea how to resolve. To the point: I've <divelement with a style "height: auto" and I want to retrieve this value...
21
by: JOYCE | last post by:
Look the subject,that's my problem! I hope someone can help me, thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.