Meine DB2-Version ist LUW v11.1.db2 "NOT LOGGED INITIALLY" funktioniert nicht
Ich führe Select-Abfragen auf große Tabellen und Einfügen in neue Tabellen, so versuche ich "NOT LOGGED INITIALLY" beim Erstellen neuer Tabellen zu verwenden, um zu vermeiden, große Größe des Protokolls zu generieren. Aber es scheint, dass die NLI-Option nicht funktioniert.
Die folgende ist mein SQL-Code:
create table diabetes_v3_2.comm_outpatient_prescription_drugs_t2dm
as (select * from commercial.outpatient_prescription_drugs)
with no data
not logged initially;
insert into diabetes_v3_2.comm_outpatient_prescription_drugs_t2dm
select * from commercial.outpatient_prescription_drugs
where enrolid in (
select enrolid from diabetes_v3_2.t2dm_cohort_filter_age_enrollment
);
create table diabetes_v3_2.comm_outpatient_services_t2dm
as (select * from commercial.outpatient_services)
with no data
not logged initially;
insert into diabetes_v3_2.comm_outpatient_services_t2dm
select * from commercial.outpatient_services
where enrolid in (
select enrolid from diabetes_v3_2.t2dm_cohort_filter_age_enrollment
);
ich das Skript als db2 -tvf script.sql
laufen. Aber ich habe immer noch die Fehlermeldung „SQL0964C Das Transaktionsprotokoll für die Datenbank voll ist“:
/* Generate cohort data for the cohort after * filtering according to age and continuous * enrollment criteria. */ /* facility header */ /* inpatient admissions */ /* inpatient services */ /* outpatient prescription drugs */ create table diabetes_v3_2.comm_outpatient_prescription_drugs_t2dm as (select * from commercial.outpatient_prescription_drugs) with no data not logged initially
DB20000I The SQL command completed successfully.
insert into diabetes_v3_2.comm_outpatient_prescription_drugs_t2dm select * from commercial.outpatient_prescription_drugs where enrolid in (select enrolid from diabetes_v3_2.t2dm_cohort_filter_age_enrollment)
Number of rows affected : 275423901
DB20000I The SQL command completed successfully.
/* outpatient services */ create table diabetes_v3_2.comm_outpatient_services_t2dm as (select * from commercial.outpatient_services) with no data not logged initially
DB20000I The SQL command completed successfully.
insert into diabetes_v3_2.comm_outpatient_services_t2dm select * from commercial.outpatient_services where enrolid in (select enrolid from diabetes_v3_2.t2dm_cohort_filter_age_enrollment)
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0964C The transaction log for the database is full. SQLSTATE=57011
Warum ist das?
Was macht dieses "AUTOCOMMIT"? Ich habe gelernt, dass, wenn ein Befehl festgeschrieben wird, NLI auf dem Tisch deaktiviert ist. Da in meinem Code nach jeder 'create table' nur ein 'insert'-Befehl mit' not logged initially' existiert, ist es mir egal, obwohl das Commit nach dem Ausführen des 'insert'-Befehls die Deaktivierung des vorherigen NLI verursacht . Ich werde keinen anderen Befehl an diesem Tisch ausführen. – panc
@PanChao Wenn Auto-Commit aktiviert ist, führt die Datenbank implizit nach jeder Anweisung einen 'COMMIT' aus. –
@fabfas Es ist eine viel bessere Idee, 'DB2OPTIONS' in Ihrer Umgebung als in der DB2-Registry zu setzen: Als Umgebungsvariable wirkt sie nur auf Ihre Shell, während sie in der Registry für alle Benutzer am Server eingestellt wird . Da dies kein Standardverhalten ist, wird es wahrscheinlich Probleme verursachen, wenn Personen erwarten, dass Autocommit aktiviert ist. –