MySQL-HM-Strukturänderung Flashcards

1
Q

Tabellentypen / Tabellentypen ändern

A
  • MySQL unterstützt verschiedene Tabellentypen
  • Standard bis 4.1 => MYISAM
  • Standard ab 5 => INNODB

InnoDB

  • trankaktionsfähig
  • Foreign Key-fähig
  • ab MySQL 4 verfügbar

alter table tabellenname

engine = tabellentyp;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Spalten hinzufügen

A
  • es können auch mehrere Spalten gleichzeitig hinzugefügt werden
  • Position durch first, after wählbar

alter [ignore] table tabellenname

add feldname1 datentyp [first],

add feldname2 datentyp [after feldname]

;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Spalte löschen

A

alter table tabellenname

drop feldname;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Primary Key hinzufügen

A

alter table tabellenname

add primary key (feldname, [feldname, …]);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Primary Key löschen

A

alter table tabellenname

drop primary key;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Index hinzufügen

A

alter table tabellenname

add index (feldname, [feldname, …]);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Index löschen

A

alter table tabellenname

drop index (indexname);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Ein Feld unique machen

A

alter table tabellenname

add unique (feldname);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Standardwert hinzufügen

A

alter table tabellenname

alter feldname set default wert;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Standardwert löschen

A

alter table tabellenname

alter feldname drop default;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Feldname und Datentyp ändern

A

alter table tabellenname

change feldname_alt feldname_neu datentyp_neu;

  • es müssen alle Parameter angegeben werden
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Datentyp ändern

A

alter table tabellenname

change feldname neuer_datentyp;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Tabelle umbenennen

A

alter table tabellenname

rename [to] neuer_tabellenname;

rename table tabellenname to neuer_tabellenname;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly