SQL Flashcards

1
Q

eine Tabelle mit Spallten erstellen

A

CREATE TABLE author (
id INT PRIMARY KEY,
firstname VARCHAR(20),
lastname VARCHAR(20),
book_id INT FOREIGN KEY REFERENCES book (id)
);

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

Datensatz hinzufügen

A

INSERT INTO author (id, firstname, lastname)
VALUES (1, ‘Hans’, ‘Wurst’), (2, ‘Petra’, ‘Musterfrau’);

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

änder eine Zelle / eine Wert

A

UPDATE author
SET blz = 12345678
WHERE id = 1;

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

löschen eine Datensatz

A

DELETE FROM Kunde
WHERE ID = 42;

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

finde Nachnamen mit M anfangen

A

select *
from Mitarbeiter
where Nachname LIKE ‘M%’:

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

finde Nachnamen die zweite Buchstabe e ist

A

WHERE nachname LIKE ‘_e%’;

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

finde Nachnamen die zweite Buchstabe a, e oder i ist

A

WHERE nachname LIKE ‘_[aei]%’;

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

was bedeutet % in regex?

A

egal welche, egal wie viel oder kann auch nichts

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

Rehienfolge SQL Syntax

A

Select
From
Where
Group By
Having
Order By

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

WHERE HAVING unterschied?

A

WHERE filtert nach ürsprungliche Daten bzw. originale Daten, aber HAVING filtert nach Ergebnis eine Gruppierung und aggregation

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

Sortierung Spallte aufsteigend

A

ORDER BY abt_id

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

Sortierung eine Spallte absteigebd und andere Spallte aufsteigend

A

ORDER BY abt_id DESC, stadt ASC;

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

modulo

A

Das Modulo mit dem Zeichen % ergibt den Rest einer Division

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

eine Spallte indizieren

A

CREATE INDEX idxdatum ON TabelleName(SpallteName )

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

einen neuen Nutzer mit Passwort anlegen

A

CREATE USER ‘Maier’ IDENTIFIED BY “Sjk26“;

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

einen Nutzer Leserecht an Tabelle zuweisen

A

GRANT SELECT ON Objekt TO ‘Maier’;

17
Q

CREATE TABLE Statement

A

CREATE TABLE Persons (
PersonID int,
LastName varchar(255),

);

18
Q

Insert Datensätze aus einer Tabelle in die andere

und löschen

A

SELECT spaltten, …, …
INTO ziel_tabelle
FROM tabelle
WHERE id = 5;

DELETE
FROM tabelle
WHERE id = 5;