Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
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.
Of course it is. You must either provide an id that's not already present or provide none at all and define your table in such a way that id will be incremented automatically. Have a look at the database documentation and search for "increment".
When multiple servers are configured as replication masters, special steps must be taken to prevent key collisions when using AUTO_INCREMENT columns, otherwise multiple masters may attempt to use the same AUTO_INCREMENT value when inserting rows.
and that's the right documentation where i have to look for :
Quote:
How to assign the AUTO_INCREMENT attribute to a column: Section 13.1.5, “CREATE TABLE Syntax”, and Section 13.1.2, “ALTER TABLE Syntax”.
I have multiple master sites could you show me how you would do it ?
It's my first sql .... it looks like there is lot of writing down ! http://dev.mysql.com/doc/refman/5.0/...ate-table.html
don't know where to start ...
Looks fine to me, why don't you just try it? You'll see that 'admin' automatically gets an id, and if you insert a new row, it'll get another id. I don't know anything about replication, but I guess it's nothing you should do unless you've got some experience with database management.
I cannot f***k up with SQL if something goes wrong .... that's how i did :
Quote:
mysql> SHOW DATABASES;
+----------+
| Database |
+----------+
| cilento |
| italian |
| mysql |
| test |
| wwwgab |
+----------+
5 rows in set (0.00 sec)
mysql> use wwwgab;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> create table users (
-> id mediumint not null auto_increment,
-> name CHAR(30) NOT NULL,
-> PRIMARY KEY (id)
-> );
Query OK, 0 rows affected (0.02 sec)
I'm sorry but it is still giving me the error i missed something sure ... !
Quote:
store:mosuser::store failed <br/>Duplicate entry '0' for key 1 SQL=INSERT INTO jos_users('id','name','username','email','password','usertype','gid','registerDate')
VALUES('0','gabrix','smith','smith@yahoo.it', ... ecc. ... )
Anyway,i don't think is necessary to create a new table.If you see the error message it says of a table jos_users and maybe i have to auto_icrement the id and modify that table ... but how ??????????????
Why would you want to create a new table? If you want a column to be incremented automatically, you'll have to specify that during creation of the table or in an "ALTER TABLE" statement. For example, if you had forgotten "AUTO_INCREMENT" in that "CREATE TABLE users" statement above, then you could add it later using
Code:
ALTER TABLE users MODIFY id MEDIUMINT NOT NULL AUTO_INCREMENT;
And if the AUTO_INCREMENT property is set for column 'id' in table 'jos_users' already, you can use the following command to add a new row, which will be assigned a new id automatically:
Code:
INSERT INTO jos_users('name','username','email','password','usertype','gid','registerDate')
VALUES('gabrix','smith','smith@yahoo.it', ... ecc. ... );
OK, so after the first statement from your last post, the 'id' column will be incremented automatically. Try "DESCRIBE users;", it will also give you that information.
But then, I think the error message you just gave doesn't belong to the INSERT statement above, as it complains about a nonexistent column named "activation" which didn't appear in that statement. And have a look at the INSERT statement from my previous post: If you want the value of 'id' to be inserted automatically, you must not specify a value in the statement. So the list of column names begins with 'name' instead of 'id':
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.