Mit dem Guide verknüpftes Quiz · Mittel Ebene
So schreiben Sie SQL-CTEs und Unterabfragen mit AI Quiz
Überprüfen Sie den CTE-Bereich, EXISTS und skalare Unterabfragen sowie Schutzmaßnahmen für rekursive Abfragen anhand von Kundenberichten und kleinen Hierarchiebeispielen.
Frage 1 von 8
Ein SELECT CTE namens customer_totals wird mit WITH definiert. Wie lange existiert dieses gewöhnliche benannte Ergebnis?
Sehen Sie sich jede Frage in der Vorschau an8 Fragen
Während Sie am Quiz teilnehmen, werden Antworten und Erklärungen angezeigt.
- Ein SELECT CTE namens customer_totals wird mit WITH definiert. Wie lange existiert dieses gewöhnliche benannte Ergebnis?
- Until the database server next restarts
- Within the larger statement that defines it
- Until a separate DROP TABLE command removes it
- Across every future query in the same application
- Ein Kunde hat drei qualifizierte Bestellungen. Wie wirkt sich eine EXISTS-Bedingung auf die äußere Zeile dieses Kunden aus?
- It automatically creates three output copies
- It adds three to every customer total
- It fails because more than one inner row exists
- It tests true without multiplying the row because of those matches
- Eine skalare PostgreSQL-Unterabfrage gibt unerwartet zwei Zeilen zurück. Welche Antwort bewahrt eine sinnvolle Auswahlregel?
- Clarify and implement which single value the query should return
- Add an unordered LIMIT merely to suppress the error
- Assume PostgreSQL will always choose the latest row
- Change the output alias and leave the subquery unchanged
- Warum sollte ein CTE von customer_totals getestet werden, bevor er mit Kundendaten verknüpft wird?
- The CTE name establishes that each customer key is unique
- An aggregate inside a CTE cannot produce repeated customer keys
- Unexpected repeated customer keys can multiply the later result
- Checking only the final row count establishes each intermediate result's grain
- Eine KI behauptet, dass das Ersetzen jeder Unterabfrage durch einen CTE immer die Leistung verbessert. Wie ist dies zu beurteilen?
- Accept it because named steps always execute once
- Check the target engine's behavior and execution plan
- Accept it because a shorter query always requires less work
- Reject every CTE because it must always be materialized
- Why might UNION fail to stop a recursive cycle when a depth column changes at each visit?
- UNION preserves every exact duplicate by definition
- Depth columns prevent any recursive query from running
- Cycles can occur only in queries using UNION ALL
- Repeated visits can remain distinct result rows because their depths differ
- A correlated subquery refers to an outer value. Which performance claim would be premature without plan evidence?
- It must physically rerun a full independent query for every outer row
- Its result logically depends on an outer value
- An optimizer may transform an eligible expression
- Its behavior should be tested on representative data
- Why should null-containing fixtures be used when rewriting a NOT IN condition?
- Nulls always behave like ordinary equal values
- NOT IN ignores every null in its comparison set
- Nulls can change the condition's truth result and the rewrite's behavior
- Adding a CTE automatically removes null-related differences