yonah wrote:
^^^^^
Da fe lt was.
> Ich hätte gern für jeden Datenbankeintrag einen Zeitstempel automatisch
> erzeugt. Jetzt möchte ich aber ungern immer eine Spalte "Zeitstempel" in
> jede Tabelle einfügen.
Das wäre aber die richtige Lösung. Der dazugehörige MySQL-Datentyp heisst
TIMESTAMP.
> Gibt es irgendwo versteckt automatisch ein Feld, was man auslesen könnte?
Nein.
> Oder wäre es sinnvoll (glaub ich eher nicht), vielleicht das ID Feld als
> Zeitfeld zu nehmen - dies wäre aber nur solange eindeutig ein Key, bis
> nicht 2 User gleichzeitig auf die DB zugreifen und 2 gleiche Zeitstempel
> erzeugen.
Du hast diese Frage selbst beantwortet.
> Wie würdet ihr das realisieren?
$ mysql -p -u root es-matrix -e
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 71
Server version: 5.5.29-1 (Debian)
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.
mysql> EXPLAIN `feature`;
+-------------+---------------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra
|
+-------------+---------------------+------+-----+-------------------+-----------------------------+
| id | int(10) unsigned | NO | PRI | NULL |
auto_increment |
| code | varchar(512) | NO | | NULL |
|
| title | varchar(255) | YES | | NULL |
|
| edition | varchar(3) | YES | | NULL |
|
| section | varchar(25) | YES | | NULL |
|
| section_urn | varchar(25) | YES | | NULL |
|
| generic | tinyint(1) unsigned | NO | | 0 |
|
| versioned | tinyint(1) unsigned | NO | | 0 |
|
| created | timestamp | YES | | NULL |
|
| modified | timestamp | NO | | CURRENT_TIMESTAMP | on
update CURRENT_TIMESTAMP |
+-------------+---------------------+------+-----+-------------------+-----------------------------+
10 rows in set (0.00 sec)
mysql> EXPLAIN `result`;
+-------------+------------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra
|
+-------------+------------------+------+-----+-------------------+----------------+
| id | int(10) unsigned | NO | PRI | NULL |
auto_increment |
| testcase_id | int(10) unsigned | NO | MUL | NULL |
|
| env_id | int(10) unsigned | NO | MUL | NULL |
|
| value | tinyint(1) | NO | | NULL |
|
| created | timestamp | NO | | CURRENT_TIMESTAMP |
|
+-------------+------------------+------+-----+-------------------+----------------+
5 rows in set (0.00 sec)
mysql> Bye
Siehe auch: <
http://dev.mysql.com/doc/refman/5.5/en/timestamp-
initialization.html>
HTH
--
PointedEars
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.