Is there a SQL script I can run in Oracle that will tell me which fields I have permission to Update?
EDIT:
I've tried these
select * from USER_COL_PRIVS_RECD
select * from DBA_COL_PRIVS
select * from USER_COL_PRIVS_MADE
select * from ALL_TAB_PRIVS_MADE
select * from ALL_TAB_PRIVS_RECD
and the only one that has results is the last one which shows table permissions but not column permissions.
I don't have a script to do this but you should be able to get your column level privileges from the USER COL PRIVS_RECD view. This site has more info: Oracle Column Level Privileges
Related
I am quite new to SQL, and my first "job" is to get something out of an Oracle SQL database.
Just to see what's actually found in my connection I use the following:
SELECT owner, table_name FROM dba_tables
This gives me a bunch of tuples with an owner name and table_name. However, some table names are the same for different owners.
So when I run a command like:
SELECT * FROM MyTableName
How do I ensure that this table is coming from owner1 and not owner2, where both of them actually have a table called MyTableName ?
You can do:
SELECT * FROM <owner>.MyTableName
You can specify exactly which table with
select * from some_owner.my_table;
If you do this:
select * from my_table;
You will be selecting from the version of MY_TABLE that belongs to the owner/user with which you you are connected to the database. So, if you connected as user SCOTT, then
select * from my_table;
effectively becomes
select * from scott.my_table;
Note that this behavior can be overridden by the use of synonyms. Suppose user SCOTT has a synonym like this:
create synonym scott.my_table for fred.my_table;
Then SCOTT issues
select * from my_table;
Then oracle will check first for a synonym, and finding it will effectively transform the query to
select * from fred.my_table;
So in the end, the precedence is this. When you reference a table without qualifying it with the owner, oracle will look for it in this sequence:
is there a user synonym by that name? if so, use what it references if the user has been granted necessary privileges.
is there a global synonym by that name? if so, use what it references if the user has been granted necessary privileges.
does the user itself own a table by that name? if so, use that table.
return error "ORA-00942: table or view does not exist"
I am new to Oracle and want to find all tables created by user 'john' .
I connect to Oracle database via command line by the following command:
sqlplus john/passwd
How do i list all the tables created by a given user e.g. john?
This will get all the tables where the "JOHN" user is the owner:
SELECT * FROM USER_TABLES;
or
SELECT * FROM ALL_TABLES WHERE OWNER = 'JOHN';
([TL;DR] 'JOHN' typically needs to be in upper-case. Assuming that the user john was created using the CREATE USER john ... statement then Oracle's default behaviour is to convert all object names (i.e. tables, columns, users, etc) to upper case. When you query the data-dictionary the table details will be stored in this case (and not the case you used in the original command unless you wrap it in double quotes).)
To list the table you can use
SELECT * FROM ALL_TABLES WHERE OWNER = 'JOHN';
TO see the size of the schema you can use
SELECT sum(bytes)
FROM dba_segments
WHERE owner = 'JOHN'
Since you are logged in as the schema owner, you can also use
SELECT SUM(bytes)
FROM user_segments
You can use also
select * from
USER_TABLES;
anyway you can find all the data dictionary explain here https://docs.oracle.com/cd/B28359_01/server.111/b28310/tables014.htm
select * from
USER_TABLES;
The above code will show all the information of the tables under the user which is currently connected. This might clutter your SQL terminal.
To Specifically see only the table names under a user you should use the following code
select table_name
from USER_TABLES;
Try:
select *
from all_tables
where owner = 'jhon';
Right, so when I run:
Select * from Consultants
I get:
ORA-00942: table or view does not exist
The table clearly exists in the object browser.
However, when I run:
select * from Customers#xe.m512Finn
I get the data requested.
Please don't tell me that the table in the local database doesn't exist because it does; I created it and it's there in the object browser.
Is there something wrong with my syntax? Please help me with any suggestions.
Here you're selecting from the Consultants table
Select * from Consultants
And here you're selecting from the Customers table
select * from Customers#xe.m512Finn
The table does exists in m512Finn user that's why it returns the values for
select * from Customers#xe.m512Finn
You might be running that query in a different schema or the query u might be looking for must be
Select * from consultants#xe.m512Finn
Okay i've resolved the issue, it's that when you query local tables, you need double quotation marks around the table name.
select * from "Consultants"
Sir,
I've a problem regarding Database.
My problem is I've Database script file.When I integtrated the script file in Database.I found all the stored procedure is visible.But tables are not visible.
I wrote the Command as follows:
select * from sysobjects where type='p'
Now all the tables is showing but fields are not.
I wrote the Command to get the fields for particular table_name targeted as
select * from table_name .
But a message is Coming like Invalid Object name as table_name.
Please help me out to find the fields of the table ...
You can use the following query to retrieve the columns of the sought-for table:
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'your table name'
You can list all columns with:
select * from sys.columns
Question: I can get the SQL Server database language by querying:
SELECT ##language
And I can get further info via
EXEC sp_helplanguage
How can I query for a column of sp_helplanguage where name= ##language
I do SELECT * FROM sp_helplanguage WHERE name='DEUTSCH'
but that obviously doesn't work.
What's the correct way to query it ?
You need to query the underlying system catalog table directlry:
SELECT * FROM sys.syslanguages WHERE name='DEUTSCH'