Get table definition in oracle sql plus [duplicate] - sql

This question already has answers here:
How to get Oracle create table statement in SQL*Plus
(3 answers)
Closed 7 years ago.
I'm new to sql and I have created table using create table table_name.
And now I want to get this table definition or let's say source code, I know command desc table_name but that's not what I want. Could you help me figure it out?

Check the function: DBMS_METADATA.GET_DDL
http://psoug.org/reference/dbms_metadata.html

Related

How to handle a column named table in database table [duplicate]

This question already has answers here:
How to deal with SQL column names that look like SQL keywords?
(17 answers)
Syntax error due to using a reserved word as a table or column name in MySQL
(1 answer)
Are quotes around tables and columns in a MySQL query really necessary?
(4 answers)
Closed 2 years ago.
I am currently working with Joomla. I want to insert a new row into #__content_types table, but there is a column named table that is currently giving me errors.
How do I insert the data despite the name of the column 'table'?
INSERT INTO #__content_types(type_id, type_title, type_alias, table, field_mappings)
VALUES
('14','SVG Image','com_view_vv.form','{"special":{"dbtable":"#__table","key":"id","type": "Corecontent","prefix":"JTable","config":"array()"},"common":{"dbtable": "#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}', '{"common": {"core_content_item_id":"id","core_title":"name","core_alais": "alias"},"special":{"imptotal":"imptotal","impmade":"impmade","clicks": "clicks","clickurl": "clickurl","custombannercode":"custombannercode","cid":"cid","purchase_type": "purchase_type","track_impressions":"track_impressions","track_clicks":"track_clicks"}}');

To see whether a column of a table is been used somewhere in the database [duplicate]

This question already has answers here:
How can we figure out that a column in my oracle table is being populated/updated by a trigger of another table?
(3 answers)
Closed 5 years ago.
How to check whether a particular column of a table is used in any other object or not in Oracle? For example I have a table EMPLOYEE which has a column BONUS. I need to check whether this column of this table is been used by any other objects like View, Package etc in the database.
You can try the following SQL to check for the table and column used within the object definition
SELECT 1
FROM all_source
WHERE type IN ('PROCEDURE','PACKAGE BODY','FUNCTION')
AND text LIKE '%EMPLOYEE%'
AND text LIKE '%BONUS%';

How do I search the name of a table, knowing only one of the table's column name in SQL? [duplicate]

This question already has answers here:
Search an Oracle database for tables with specific column names?
(4 answers)
Closed 7 years ago.
I'm trying to find a table containing a column that I know the name to. Is there some way to do a table search using only the name of the column?
In oracle
select * from user_tab_columns where column_name= '';

Displaying the name and data type of every column in a table [duplicate]

This question already has answers here:
How To Find Datatypes information in oracle schema?
(2 answers)
Closed 9 years ago.
I am working on a Database Management Systems assignment and have been unable to find a way to display the name and datatype of every column in a specific table. I don't know if this is needed but here is the link to the schema I am using for this assignment.
http://mym.cdn.laureate-media.com/2dett4d/Walden/ITEC/ITEC2060/documents/Schema.sql
The employee table is what I am trying to display from.
To list all columns for a specific table:
select column_name, data_type
from all_tab_columns
where table_name = 'EMPLOYEES';
More details in the manual: http://docs.oracle.com/cd/E11882_01/server.112/e25513/statviews_2103.htm#I1020277
If you are using SQL*Plus you can simply run
desc EMPLOYEES
instead.
Most other SQL clients have a similar feature.

Get list of table names in different schema of an Oracle database [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Oracle: get list of all tables?
How do I list all tables in a schema in Oracle SQL?
I want to list all table in another schema.
connect hr/hr;
select table_name from user_tables;
but I want to skip the "connect" command. I want to run query from another schema.
Is that possible to do?
SELECT TABLE_NAME
FROM ALL_TABLES
WHERE OWNER='OTHER-SCHEMA'