Hi,

ich möchte ein schlechtes Datenbankdesign einer MYSQl Tabelle ändern.

In dieser Tabelle werden Tageseinträge gespeichert. Das Datum wird dabei als CHAR(8) im Format YYYMMDD gespeichert. Das halte ich nicht für sinnvoll, daher möchte ich eine Spalte 'date1' einfügen, die das Datum als date- Datentyp speichert. Also die Spalte anlegen ist kein Problem, aber kann ich mit SQL Kommandos diese Spalte automatisch anhand des Inhaltes der date- Spalte füllen, oder muss ich mir ein externes Skript dazu bauen?

Danke für die Unterstützung,

Andreas

Code:
--
-- Tabellenstruktur für Tabelle `stockprice`
--

CREATE TABLE IF NOT EXISTS `stockprice` (
  `stock_id` int(10) unsigned NOT NULL,
  `date` char(8) NOT NULL,
  `open` float(12,4) DEFAULT NULL,
  `high` float(12,4) DEFAULT NULL,
  `low` float(12,4) DEFAULT NULL,
  `close` float(12,4) DEFAULT NULL,
  `vol` int(10) unsigned DEFAULT NULL,
  `oi` int(10) unsigned DEFAULT NULL,
  KEY `stock_id` (`stock_id`),
  KEY `date` (`date`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Daten für Tabelle `stockprice`
--

INSERT INTO `stockprice` (`stock_id`, `date`, `open`, `high`, `low`, `close`, `vol`, `oi`) VALUES
(1, '19910101', 0.8960, 0.8960, 0.8960, 0.8960, 0, NULL),
(2, '19910101', 0.9830, 0.9830, 0.9830, 0.9830, 0, NULL),
(3, '19910101', 0.4000, 0.4000, 0.4000, 0.4000, 0, NULL);