Thursday, May 14, 2020

java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

You saw this error when you execute a query.


java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)
        at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1017)
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:655)


To fix it, login to the database to verify if the table or view exists.

If the table or view does not exist, create the table or view.

If the table or view is there, check to see if the table or view belongs to the correct schema using the SQL below.

      select owner, table_name from all_tables where table_name='<table name>';

If the owner of the table is other than what you have expected, create the table with the correct schema. Usually, the owner is also the schema name.

    create table <correct schema>.<table name> as select * from <unexpected schema>.<table name>; 

-----------------------------------------------------------------------------------------------------------------
Watch the blessing and loving online channel: SupremeMasterTV live




If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book for free here.

Wednesday, May 13, 2020

PostgreSQL: Monitoring the status of your queries currently running in the database


The pg_stat_activity view has one row per server process, showing information related to the current activity of that process.

pg_stat_activity view
ColumnTypeDescription
datidoidOID of the database this backend is connected to
datnamenameName of the database this backend is connected to
pidintegerProcess ID of this backend
usesysidoidOID of the user logged into this backend
usenamenameName of the user logged into this backend
application_nametextName of the application that is connected to this backend
client_addrinetIP address of the client connected to this backend. If this field is null, it indicates either that the client is connected via a Unix socket on the server machine or that this is an internal process such as autovacuum.
client_hostnametextHost name of the connected client, as reported by a reverse DNS lookup of client_addr. This field will only be non-null for IP connections, and only when log_hostname is enabled.
client_portintegerTCP port number that the client is using for communication with this backend, or -1 if a Unix socket is used
backend_starttimestamp with time zoneTime when this process was started, i.e., when the client connected to the server
xact_starttimestamp with time zoneTime when this process' current transaction was started, or null if no transaction is active. If the current query is the first of its transaction, this column is equal to the query_start column.
query_starttimestamp with time zoneTime when the currently active query was started, or if state is not active, when the last query was started
state_changetimestamp with time zoneTime when the state was last changed
waitingbooleanTrue if this backend is currently waiting on a lock
statetextCurrent overall state of this backend. Possible values are:
  • active: The backend is executing a query.
  • idle: The backend is waiting for a new client command.
  • idle in transaction: The backend is in a transaction, but is not currently executing a query.
  • idle in transaction (aborted): This state is similar to idle in transaction, except one of the statements in the transaction caused an error.
  • fastpath function call: The backend is executing a fast-path function.
  • disabled: This state is reported if track_activities is disabled in this backend.
querytextText of this backend's most recent query. If state is active this field shows the currently executing query. In all other states, it shows the last query that was executed.

For example, you can use the following query to see the state, text, and running period of your statement.

SELECT pid, usename, query, state, age(clock_timestamp(), query_start)
FROM pg_stat_activity
WHERE usename = '<your database login>';

If you want to see if your query is holding or waiting on any locks, you can run the query below.

SELECT a.pid, a.state, L.mode, L.locktype, L.granted
FROM pg_stat_activity a
INNER JOIN pg_locks L on a.pid = L.pid
WHERE a.usename = '<your database login>'
order by L.granted desc;



References:

-----------------------------------------------------------------------------------------------------------------
Watch the blessing and loving online channel: SupremeMasterTV live




If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book for free here.