Search code examples
databaseoracle-databaseselectplsqloracle19c

Table gets auto-cleared when session is closed in OracleDB


I have this oracle db instance

C:\> set ORACLE_SID=orcl;
C:\> sqlplus / as sysdba

When I am creating table and adding few rows in it

SQL> SELECT table_name
     FROM user_tables
     ORDER BY table_name;

SQL> INSERT ALL  
     INTO customers (customer_id , customer_name, city  ) VALUES (1, 'Aman', 'Ranchi')
     INTO customers (customer_id , customer_name, city  ) VALUES (2, 'Akib', 'Purulia') 
     SELECT * FROM dual;

enter image description here

SQL> UPDATE customers  
     SET customer_name = 'Aashi'
     WHERE customer_id = 1;  

Now when I am logging out/quitting

SQL > Ctrl^C

And logging in again, This is what I am getting no rows selected

enter image description here

Why were my changes not affected?


Solution

  • It looks like you neglected to commit your changes. When you forcibly terminated SQL*Plus rather than gracefully logging out, Oracle rolled back your changes.

    Separately, if you are going to create objects in your database, please don't log in as sys or create them in the sys schema (or the system tablespace). Create a new user that will own your objects, create a tablespace for user objects for that user to use, and log in as that user to create the objects. Creating objects in the sys schema isn't supported and there are features that behave differently in sys than they do elsewhere.