vault backup: 2026-07-23 08:55:19

This commit is contained in:
Benjamin Neumann
2026-07-23 08:55:19 +02:00
parent c38b4e4c19
commit 1de34419bc
@@ -25,13 +25,45 @@ FOREIGN KEY A REFERENCES B(A)
### ALTER TABLE ### ALTER TABLE
``` ```
ALTER TABLE table_name ALTER TABLE table_name #vor allen Befehlen
--- ---
ADD column_name data_type [constraint]; ADD column_name data_type [constraint];
--- ---
DROP COLUMN column_name DROP COLUMN column_name;
--- ---
ALTER COLUMN column_name new_data_type ALTER COLUMN column_name new_data_type;
---
ADD CONSTRAINT constraint_name constraint_type (column_name);
---
DROP CONSTRAINT constraint_name;
``` ```
DROP TABLE (IF EXISTS) table_name : löscht Tabelle + Daten
### CREATE VIEW
Erstellt Relation mit der gearbeitet werden kann
Bsp.:
```
CREATE VIEW Langzeit_Studierende AS
SELECT * FROM Student WHERE Semester >= 10;
```
DROP VIEW Name zum löschen
### Indexe
Effizienteres Suchen in Tabellen
```
CREATE [UNIQUE] INDEX <name>
ON <Relationsname> (<Attributname> [<Ordnung>]{, <Attributname>
[<Ordnung>]})
```
UNIQUE für eindeutigen Index optional
Relationsname = Tabelle
Attributname = Spalte
Ordnung = ASC / DESC
Bsp.:
```
CREATE UNIQUE INDEX idx_student_semester
ON Student (Semester ASC);
```
DROP INDEX Name zum löschen