What will be the query in oracle? - oracle

How to write this sql query into Oracle.
ALTER TABLE student MODIFY 'student_balance' DOUBLE(20,5)
As i am new in oracle so can anybody suggest some good sites to learn oracle queries again

Use number instead of double
Alter table student MODIFY student_balance number(20,5)
For more refer here .

Related

plsql. is there way to get column ddl?

I use dbms_metadata.get_ddl(...) to get object ddl but it is not generate ddl for column.
is there way to get column ddl oracle 12 version?
thanks
I think following query may usefull for you.
SELECT *
FROM ADMIN.DDL_HISTORY_LOG L
WHERE L.OBJECT_TYPE = 'TABLE'
AND L.DDL = 'ALTER'
AND L.OBJECT_NAME = 'TABLE_NAME' --just change table name here
AND UPPER(L.DDL_SQL) LIKE '%ALTER%TABLE%ADD%'
AND UPPER(L.DDL_SQL) NOT LIKE '%ADD%CONSTRAINT%'
this oracle dictionary is holding all historic DDL statements. so, If you specify your table name, you can get all DDL statements for this table in the past.

how to fetch last access TIMESTAMP of a table in oracle?

How to fetch the last access date for a table in oracle using the query from Oracle DB?
I am using select TIMESTAMP from dba_tab_modifications query it's giving me last updates in table
but I need last execution of select query statement on a particular table
Thanks in Advance
Sai Kumar
Oracle does not keep this information by default. You need to enable the appropriate AUDIT rules. But I'd question what problem you think this will solve. Auditing every access to a table will be a lot of audit records.

Script to compare Oracle Schema with Teradata Views

I have a task to compare some Teradata Views with actual Oracle Tables.
I need a script for that.I have taken Java approach in which I connect to a specific schema from Oracle and then call the SELECT * FROM all_tables order by TABLE_NAME query and write this into a file.
I do the same for other schema but now my problem is Teradata.
Can you people please suggest me some script or query by which I can get proper details like it does with Oracle.
There is no complex Java Code but if you still want I can post it.
Edited:
Okay now I have a schema in Oracle which has all the tables.so views for those tables are created in Teredata.
I have to compare oracle tables and Teradata views every morning and send the differances.
So I use SELECT * FROM all_tables order by TABLE_NAME in Oracle and for Teradata I use SELECT * FROM dbc.tables WHERE tablekind='V' AND databasename='SCHEMA' order by TableName so now when I compare them I dont get accurate results, so I wanted to know does any script exists or how do I approach.
If your question is "How can I programmatically determine the structure of a view in Teradata?", then this should be a step in the right direction: HELP VIEW yourviewname;.
To get a list of views on a given table:
SELECT TableName
FROM DBC.Tables
WHERE Tablekind = 'V'
AND requestText LIKE '%yourtablename%'
GROUP BY 1
ORDER BY 1;
This information was gleaned from the official Teradata forums. You might also be interested in the Teradata users manuals. (Select your release version on the top right.)

How to create a table identical to other table in structure and constraints in Oracle?

I want to create a table (lets say table_copy) which has same columns as other table (lets call it table_original) in Oracle database, so the query will be like this :
create table table_copy as (select * from table_original where 1=0);
This will create a table, but the constraints of table_original are not copied to table_copy, so what should be done in this case?
Only NOT NULL constraints are copied using Create Table As Syntax (CTAS). Others should be created manually.
You might however query data dictionary view to see the definitions of constraints and implement them on your new table using PL/SQL.
The other tool that might be helpful is Oracle Data Pump. You could import the table using REMAP_TABLE option specifying the name for the new table.
Use a database tool to extract the DDL needed for the constraints (SQL Developer does the job). Edit the resulting script to match the name of the new class.
Execute the script.
If you need to do this programmatically you can use a statement like this:
DBMS_METADATA.GET_DDL('TABLE','PERSON') from DUAL;

Recording sql statements performing on a table in Oracle

Is there a way to record sql statements performing on table in Oracle? I need to record those queries for a table in production and hopefully rerun them in my test to make sure I don't mess up table modification.
Thanks,
Sean
Oracle Database Replay is exactly the feature you are looking for: http://www.oracle.com/technetwork/articles/sql/11g-replay-099279.html
Oracle automatically records any SQL executed against the instance in a table called v$sqlarea

Resources