Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.
Passaggio 4: interrogare le tabelle in un libro mastro
Importante
Avviso di fine del supporto: i clienti esistenti potranno utilizzare Amazon QLDB fino alla fine del supporto il 31/07/2025. Per ulteriori dettagli, consulta Migrare un Amazon QLDB Ledger ad Amazon Aurora Postgre
Dopo aver creato tabelle in un QLDB registro Amazon e averle caricate con i dati, puoi eseguire query per rivedere i dati di immatricolazione dei veicoli che hai appena inserito. QLDButilizza PartiQL come linguaggio di interrogazione e Amazon Ion come modello di dati orientato ai documenti.
PartiQL è un linguaggio di query open source e SQL compatibile che è stato esteso per funzionare con Ion. Con PartiQL, puoi inserire, interrogare e gestire i tuoi dati con operatori familiariSQL. Amazon Ion è un superset di. JSON Ion è un formato di dati open source basato su documenti che offre la flessibilità di archiviazione ed elaborazione di dati strutturati, semistrutturati e annidati.
In questo passaggio, si utilizzano SELECT
le istruzioni per leggere i dati dalle tabelle del registro. vehicle-registration
avvertimento
Quando si esegue una query QLDB senza una ricerca indicizzata, viene richiamata una scansione completa della tabella. PartiQL supporta tali interrogazioni perché è compatibile. SQL Tuttavia, non eseguite scansioni di tabelle per casi d'uso di produzione in. QLDB Le scansioni delle tabelle possono causare problemi di prestazioni su tabelle di grandi dimensioni, inclusi conflitti di concorrenza e timeout delle transazioni.
Per evitare le scansioni delle tabelle, è necessario eseguire istruzioni con una clausola di WHERE
predicato utilizzando un operatore di uguaglianza su un campo indicizzato o un ID di documento; ad esempio, o. WHERE indexedField = 123
WHERE indexedField IN (456, 789)
Per ulteriori informazioni, consulta Ottimizzazione delle prestazioni delle query.
Per interrogare le tabelle
-
Compila ed esegui il seguente programma (
FindVehicles.java
) per interrogare tutti i veicoli registrati con una persona nel tuo registro.Nota
Innanzitutto, questo programma interroga la
Person
tabella del documento per ottenere il relativo campoGovId LEWISR261LL
di metadati.id
Quindi, utilizza questo documento
id
come chiave esterna per interrogare laVehicleRegistration
tabella.PrimaryOwner.PersonId
Inoltre si unisceVehicleRegistration
allaVehicle
tabella sulVIN
campo.
Per ulteriori informazioni sulla modifica dei documenti nelle tabelle del vehicle-registration
registro, vedere. Fase 5: Modificare i documenti in un libro mastro