diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index 75fd39d..41d322c 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -220,6 +220,7 @@ "lastOpenFiles": [ "SS2026/Datenbanken und Informationssysteme/SQL/Anhänge/sql_merged.pdf", "SS2026/Datenbanken und Informationssysteme/SQL/SQL.md", + "SS2026/Datenbanken und Informationssysteme/SQL/DDL Data Definition Language SQL.md", "SS2026/Datenbanken und Informationssysteme/Datenbanken und Informationssysteme.md", "SS2026/Klausurplan.canvas", "SS2026/Datenbanken und Informationssysteme/Relationales Datenmodell/Relationales Datenmodell.md", diff --git a/SS2026/Datenbanken und Informationssysteme/SQL/DDL Data Definition Language SQL.md b/SS2026/Datenbanken und Informationssysteme/SQL/DDL Data Definition Language SQL.md new file mode 100644 index 0000000..1bdd3ac --- /dev/null +++ b/SS2026/Datenbanken und Informationssysteme/SQL/DDL Data Definition Language SQL.md @@ -0,0 +1,59 @@ + + +### CREATE TABLE +``` +CREATE TABLE table_name ( + column_name1 data_type1 constraints1, + ... +) +``` +names = Namen +type = Datentyp INTEGER, CHAR(n), DATE... +constraints = NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY... +FOREIGN KEY A REFERENCES B(A) + +### ALTER TABLE + +``` +ALTER TABLE table_name #vor allen Befehlen +--- +ADD column_name data_type [constraint]; +--- +DROP COLUMN column_name; +--- +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 +ON ( []{, +[]}) +``` +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 \ No newline at end of file diff --git a/SS2026/Datenbanken und Informationssysteme/SQL/SQL.md b/SS2026/Datenbanken und Informationssysteme/SQL/SQL.md index 43a8bd3..996f0c6 100644 --- a/SS2026/Datenbanken und Informationssysteme/SQL/SQL.md +++ b/SS2026/Datenbanken und Informationssysteme/SQL/SQL.md @@ -8,62 +8,19 @@ Duplikate möglich!!! 1. CREATE TABLE: zum Erstellen einer neuen Tabelle 2. ALTER TABLE: zum Ändern einer bestehenden Tabelle 3. DROP TABLE: zum Löschen einer Tabelle +[[DDL Data Definition Language SQL]] +## SQL Data Manipulation Language DML +1. INSERT +2. UPDATE +3. DELETE -### CREATE TABLE +### INSERT ``` -CREATE TABLE table_name ( - column_name1 data_type1 constraints1, - ... -) -``` -names = Namen -type = Datentyp INTEGER, CHAR(n), DATE... -constraints = NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY... -FOREIGN KEY A REFERENCES B(A) - -### ALTER TABLE - -``` -ALTER TABLE table_name #vor allen Befehlen ---- -ADD column_name data_type [constraint]; ---- -DROP COLUMN column_name; ---- -ALTER COLUMN column_name new_data_type; ---- -ADD CONSTRAINT constraint_name constraint_type (column_name); ---- -DROP CONSTRAINT constraint_name; +INSERT INTO (spalte1, spalte2, ...) VALUES (wert1, wert2, ...); ``` -DROP TABLE (IF EXISTS) table_name : löscht Tabelle + Daten - -### CREATE VIEW -Erstellt Relation mit der gearbeitet werden kann -Bsp.: +### UPDATE ``` -CREATE VIEW Langzeit_Studierende AS - SELECT * FROM Student WHERE Semester >= 10; +UPDATE SET spalte1 = wert1, spalte2 = wert2, ... WHERE ; ``` -DROP VIEW Name zum löschen - -### Indexe -Effizienteres Suchen in Tabellen -``` -CREATE [UNIQUE] INDEX -ON ( []{, -[]}) -``` -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