List:General Discussion« Previous MessageNext Message »
From:BAUMEISTER Alexandre Date:July 5 2000 9:32am
Subject:Bug?: Timestamp(4) PRIMARY KEY NOT UNIQUE
View as plain text  
Bonjour,

  I created a table with the primary key as timestamp(4) :

CREATE TABLE actifs_mois (
  mois timestamp(4),
  nb int(11) DEFAULT '0' NOT NULL,
  PRIMARY KEY (mois)
);

mysql> desc actifs_mois;
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| mois  | timestamp(4) | YES  | PRI | NULL    |       |
| nb    | int(11)      |      |     | 0       |       |
+-------+--------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

  But when I insert some lines in it with query :

REPLACE INTO actifs_mois SELECT CURDATE(),connexions FROM membres.connexions_jour;

  (this query is done once a day so each time CURDATE() is different.)

  Then I retrieve duplicate primary keys from actifs_mois :

mysql> select * from actifs_mois;
+------+--------+
| mois | nb     |
+------+--------+
| 0006 | 178899 |
| 0006 | 179775 |
| 0006 | 180419 |
| 0006 | 179946 |
| 0006 | 179516 |
| 0007 | 178334 |
| 0007 | 177786 |
| 0007 | 177291 |
| 0007 | 178211 |
+------+--------+
9 rows in set (0.00 sec)


  Why ???

  Is it because I insert CURDATE() in TIMESTAMP(4) ???

  CURDATE() is different each time I run the QUERY, but TIMESTAMP(4)
  is the same during a full month ( timestamp(4) = YYMM )

  So, what's happening ?

  Regards,
  Alex.


Thread
substract tablesAlan Mizrahi29 Jun
  • Re: substract tablesJan Dvorak29 Jun
    • New web site probsJames Treworgy29 Jun
      • Re: New web site probsThimble Smith29 Jun
    • ASP to PHP??Nwakaji Eppie30 Jun
      • Re: ASP to PHP??Tomas Persson30 Jun
        • Create TableEtienne Roze30 Jun
          • Re: Create TableJerome Abela30 Jun
    • Bug?: Timestamp(4) PRIMARY KEY NOT UNIQUEBAUMEISTER Alexandre5 Jul
      • Re: Bug?: Timestamp(4) PRIMARY KEY NOT UNIQUEJerome Abela5 Jul
  • Re: substract tablessinisa29 Jun