SQL to Show Database Information

Your rating: None Average: 3.7 (3 votes)

Here is a quick SQL snippet to show some Database information. I'm only pulling Database name, date created, database owner Id and database long name.

SELECT A.NAME,
  B.DBNAME,
  A.CREATED,
  B.OWNERID,
  C.LONGNAME
FROM V$DATABASE A,
  PS.PSDBOWNER B,
  PSOPTIONS C;

Please try to help out with unanswered topics on the forum. Chances are you have had the same issue/question some time in your IT career!

Comments

Have a question? Please ask it on the forum instead.
Laura McCracken's picture
Laura McCracken (not verified)
SQL Script

Hello,
Could you help me? I need to place a script on a page in my website that displays the affiliates names and state they live in -
from the newest to the oldest.

Just for example sake lets say my database name is: affiliates
the fields involved are firstname, lastname, state ...

Could you show me the script that would do that?

Thank you.

CompShack's picture
User offline. Last seen 6 years 9 weeks ago. Offline
Joined: 12/09/2007
Posts: 167
Lets See

I'm thinking you mean table name affiliates and not database name. you will need to find a way to display the results on your page but the SQL to pull the data from the database would look something like this:

SELECT firstname, lastname, state
FROM affiliates
GROUP BY firstname, lastname, state
ORDER BY date DESC
-- the order by is to order affiliates from the newest to the oldest

n/a
Naveed's picture
Naveed (not verified)
SQL to Show Database Information

Hi, how to display the hoststring/database name in SQL.
I mean we have 'show user' in SQL, like this do we have any command to display database.