I need data dictionary view that gets all info about all data dictionary view details in oracle
select * from user_dba;
desc dba_directiories;
It is called dictionary.
Looks like this:
SQL> desc dictionary
Name Null? Type
----------------------------------------- -------- ----------------------------
TABLE_NAME VARCHAR2(30)
COMMENTS VARCHAR2(4000)
You can query it like this (for example, searching for ones that talk about "constraints"):
SQL> select * From dictionary where lower(comments) like '%constraint%';
TABLE_NAME COMMENTS
------------------------- --------------------------------------------------
ALL_CONSTRAINTS Constraint definitions on accessible tables
ALL_CONS_COLUMNS Information about accessible columns in constraint
definitions
USER_CONSTRAINTS Constraint definitions on user's own tables
USER_CONS_COLUMNS Information about accessible columns in constraint
definitions
SQL>
You can use following query on system-supplied DICTIONARY view which contains the names and abbreviated descriptions of all data dictionary views.
SELECT * FROM DICTIONARY ORDER BY 1
It has mainly divided into 3 sets. So the views with
- Prefix DBA_ show all relevant information in the entire database. DBA_ views are intended only for administrators.
- Prefix ALL_ refer to the user's overall perspective of the database. These views return information about schema objects to which the user has access through public or explicit grants of privileges and roles, in addition to schema objects that the user owns.
- Prefix USER_ views most likely to be of interest to typical database users are those with the prefix USER_.
Related
When I run following query for recent changes in a database, I noticed that my table types come with a prefix and suffix.
Why is that so for table types?
SELECT type, type_desc, name, create_date, modify_date
FROM sys.objects
ORDER BY create_date desc
User defined table types should primarily be thought of as types. This means that when trying to locate metadata about them, your starting point should be sys.types (or sys.table_types, specifically), where you will find the objects named without prefix or suffix.
Further, when wanting to explore the schema of a table type, one should be using type_table_object_id from sys.table_types to find the appropriate sys.object, rather than trying to locate them by name.
Within sys.objects, we can note two important things - these objects are in fact part of the sys schema, and are marked as is_ms_shipped. These objects, specifically, are considered to be system objects. That they all exist within the sys schema but need unique names points to one reason for needing suffixes. That they also share the sys schema with other system objects points to a reason for needing a prefix.
So I'd say the TT_ prefix is to avoid naming collisions with other object types within the sys schema, and the _47DBAE45 suffix is to avoid conflicts between multiple table types where the types themselves have the same names but exist in different schemas.
Having created two Students table types, one in dbo (as shown in the question) and one in Xyz, I run the following query:
select SCHEMA_NAME(tt.schema_id), tt.name,
SCHEMA_NAME(so.schema_id),so.name,
so.is_ms_shipped
from sys.table_types tt
inner join sys.objects so
on tt.type_table_object_id = so.object_id
Shows this result:
name name is_ms_shipped
------------- ----------- --------- ----------------------- -------------
dbo Students sys TT_Students_01142BA1 1
Xyz Students sys TT_Students_02FC7413 1
I have more than 150 schemas in PostgreSQL, every time when I perform an action a new schema will be created with some random name with numbers. It is hard to find which is the new schema created.
I use \dn to list schemas in PostgreSQL, but it doesn't display schemas in created order. How do I list either recently created schema or schemas sorted by creation date?
Any schema has oid column - numeric unique identifier (that is increased only). So you can use ORDER BY oid DESC
SELECT * FROM pg_namespace ORDER BY oid DESC LIMIT 10;
Pavel's answer is good and may get you everything you need, but if you want more flexibility, I would recommend using event triggers:
CREATE TABLE schema_creation_history
(schema regnamespace primary key,
created timestamp with time zone not null default now()
);
CREATE FUNCTION log_schema_create() RETURNS event_trigger
LANGUAGE plpgsql AS
$$
BEGIN
INSERT INTO schema_creation_history (schema) SELECT objid::regnamespace FROM pg_event_trigger_ddl_commands();
END;
$$
;
CREATE EVENT TRIGGER schema_create_trigger
ON ddl_command_end
WHEN TAG IN ('CREATE SCHEMA')
EXECUTE FUNCTION log_schema_create();
# create schema test;
CREATE SCHEMA
# select * from schema_creation_history ;
schema | created
--------+------------------------------
test | 2019-09-11 12:32:21.16346+00
(1 row)
You could add another trigger for DROP SCHEMA to make sure the table is cleaned up.
How to get all table names in salesforce data using query. for example, In postgreSQL If i give SELECT table_name FROM information_schema.tables , it will give all table names from information_schema. Same way how can i get all table names from salesforce data?.
You can't do this with a query, but you can use the describeGlobal call (via SOAP or REST), or the Schema object in apex to obtain schema information include table & field names, types, etc.
I'm trying to implement a feature whereby, apart from all the reports that I have in my system, I will allow the end user to create simple reports. (not overly complex reports that involves slicing and dicing across multiple tables with lots of logic)
The user will be able to:
1) Select a base table from a list of allowable tables (e.g., Customers)
2) Select multiple sub tables (e.g., Address table, with AddressId as the field to link Customers to Address)
3) Select the fields from the tables
4) Have basic sorting
Here's the database schema I have current, and I'm quite certain it's far from perfect, so I'm wondering what else I can improve on
AllowableTables table
This table will contain the list of tables that the user can create their custom reports against.
Id Table
----------------------------------
1 Customers
2 Address
3 Orders
4 Products
ReportTemplates table
Id Name MainTable
------------------------------------------------------------------
1 Customer Report #2 Customers
2 Customer Report #3 Customers
ReportTemplateSettings table
Id TemplateId TableName FieldName ColumnHeader ColumnWidth Sequence
-------------------------------------------------------------------------------
1 1 Customer Id Customer S/N 100 1
2 1 Customer Name Full Name 100 2
3 1 Address Address1 Address 1 100 3
I know this isn't complete, but this is what I've come up with so far. Does anyone have any links to a reference design, or have any inputs as to how I can improve this?
This needs a lot of work even though it’s relatively simple task. Here are several other columns you might want to include as well as some other details to take care of.
Store table name along with schema name or store schema name in additional column, add column for sorting and sort order
Create additional table to store child tables that will be used in the report (report id, schema name, table name, column in child table used to join tables, column in parent table used to join tables, join operator (may not be needed if it always =)
Create additional table that will store column names (report id, schema name, table name, column name, display as)
There are probably several more things that will come up after you complete this but hopefully this will get you in the right direction.
I want to begin by stating I'm an SQL noob, so I'd appreciate any suggestions or comments on my workflow and/or mindset when trying to solve this issue.
What I'm doing is gathering usage statistics about several applications, in several categories (not all categories necessarily apply to all applications), storing them in a database.
I've set up a few tables to do that, and then one table to link everything together that's structured like so (from now on: Dtable):
(column name - details)
UserID - foreign key to another table which stores users data
ApplicationID - foreign key to another table which stores applications data
CategoryID - foreign key to another table which holds a list of different categories
Value - the actual data
Each application gathers the data, then submits it to the database using a stored procedure. As the amount of data can be different based on actual usage (not always sending every category) and for each application, I was thinking of sending the data as a DataTable with a list of CategoryID and Value so I won't have to call a procedure for every individual category (Ptable).
I need to update each record in Dtable to the correct value in Ptable according to CategoryID, but also filtered by UserID and ApplicationID. UserID and ApplicationID will be given as two other parameters to the Stored Procedure. Ptable only contains a list of CategoryID / Value records.
Now, I read about Cursors (for each record in the table parameter set the relevant data in the database table), but the consensus seems to be "Avoid at all costs".
How would I go about updating the table, then, based on the varying records in Ptable?
P.S.
The tables are structured like so to keep agility and scalability in adding more categories/applications in the future. If there's a better way to do it I'll be happy to know.
I believe the update statement would look something like this, where #ApplicationID and #UserID are the stored proc's other parameters:
update Dtable
set Dtable.Value = p.Value
from Ptable p
where Dtable.UserID = #UserID
and Dtable.ApplicationID = #ApplicationID
and Dtable.CategoryID = p.CategoryID;