Bonsoir,
j'ai actuellement la table suivante :
Je souhaite obtenir la table suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 CREATE TABLE tTable1 ( table1_i_id BIGINT UNSIGNED NOT NULL, table1_i_subref INT UNSIGNED NOT NULL, table1_i_key MEDIUMINT UNSIGNED, table1_t_updated TIMESTAMP, table1_t_received TIMESTAMP NOT NULL, use_i_id INT UNSIGNED NOT NULL, table1_s_md5sum CHAR(32) NOT NULL, table1_ee_stage SET('photo_exist','archived') NOT NULL, table1_b_card TINYINT UNSIGNED NOT NULL DEFAULT '0', table1_e_error ENUM('revoked','blacklisted'), PRIMARY KEY (table1_i_id,table1_i_subref), KEY (use_i_id,table1_s_md5sum(4)), INDEX (table1_i_id,table1_t_received), INDEX(table1_i_key) ) TYPE=InnoDB;
C'est à dire renommer le champs :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 CREATE TABLE tTable1 ( table1_i_id bigint unsigned NOT NULL, table1_i_subref int unsigned NOT NULL, table1_i_key mediumint unsigned, table1_t_updated timestamp, table1_t_received timestamp NOT NULL, use_i_id int unsigned NOT NULL, table1_s_md5sum char(32) NOT NULL, table1_ee_stage set('photo_exist','archived') NOT NULL, source_i_id INTEGER(3) UNSIGNED NOT NULL , table1_e_error enum('revoked','blacklisted'), PRIMARY KEY (table1_i_id,table1_i_subref), KEY (use_i_id,table1_s_md5sum(4)), INDEX (table1_i_id,table1_t_received), INDEX (table1_i_key), KEY (source_i_id), FOREIGN KEY(source_i_id) REFERENCES tSource (source_i_id) ) TYPE=InnoDB;
en :
Code : Sélectionner tout - Visualiser dans une fenêtre à part table1_b_card TINYINT UNSIGNED NOT NULL DEFAULT '0',
et ajouter ces 2 lignes :
Code : Sélectionner tout - Visualiser dans une fenêtre à part source_i_id INTEGER(3) UNSIGNED NOT NULL
Est-ce que quelqu'un pourrait m'indiquer comment cela se fait. J'ai essayé plusieurs combinaisaisons d'écriture sans parvenir à obtenir ce que je souhaite.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 KEY (source_i_id), FOREIGN KEY(source_i_id) REFERENCES tSource (source_i_id)
Merci
Partager