SQL & PL/SQL :: Column Of Table With Data Type Varchar2 - Corresponding Index
Jan 10, 2013
I have an index on column of table which of data type varchar2. While selecting data from that table I am using following scenarios in where on the indexed column
like '%abc%'
like 'abc%'
like '&abc'
Will be the corresponding index will be for those cases?
title varchar2(100) y publisher varchar2(20) y categoryname varchar2(20) y rating varchar2(2) y
my query is, select ROWNUM AS "Rank",title,publisher from (select rating,title,publisher from bookshelf_test order by rating desc ) where ROWNUM <=3
returns result ,
1 1 MY LEDGER KOCH PRESS 2 2 TO KILL A MOCKINGBIRD HARPERCOLLINS 3 3 THE MISMEASURE OF MAN W.W. NORTON
But inner query (select rating,title,publisher from bookshelf_test order by rating desc ) returns,
1 5 WONDERFUL LIFE W.W.NORTON 2 5 THE MISMEASURE OF MAN W.W. NORTON 3 5 TO KILL A MOCKINGBIRD HARPERCOLLINS 4 5 MY LEDGER KOCH PRESS 5 4 TRUMAN SIMON SCHUSTER 6 4 GOSPEL PICADOR 7 4 HARRY POTTER AND THE GOBLET OF FIRE SCHOLASTIC 8 4 INNUMERACY VINTAGE BOOKS 9 4 JOHN ADAMS SIMON SCHUSTER 10 4 JOURNALS OF LEWIS AND CLARK MARINER 11 4 LETTERS AND PAPERS FROM PRISON SCRIBNER 12 4 PREACHING TO HEAD AND HEART ABINGDON PRESS 13 4 THE SHIPPING NEWS SIMON SCHUSTER 14 4 THE GOOD BOOK BARD 15 4 THE DISCOVERERS RANDOM HOUSE 16 3 THE COST OF DISCIPLESHIP TOUCHSTONE 17 3 SHOELESS JOE MARINER 18 3 KIERKEGAARD ANTHOLOGY PRINCETON UNIV PR 19 3 EMMA WHO SAVED MY LIFE ST MARTIN'S PRESS 20 3 EITHER/OR PENGUIN 21 3 CHARLOTTE'S WEB HARPERTROPHY 22 3 BOX SOCIALS MARINER 23 3 ANNE OF GREEN GABLES GRAMMERCY 24 3 WEST WITH THE NIGHT NORTH POINT PRESS 25 3 UNDER THE EYE OF THE CLOCK ARCADE PUB 26 3 TRUMPET OF THE SWAN HARPERCOLLINS 27 2 COMPLETE POEMS OF JOHN KEATS VIKING 28 1 POLAR EXPRESS HOUGHTON MIFFLIN 29 1 GOOD DOG, CARL LITTLE SIMON 30 1 MIDNIGHT MAGIC SCHOLASTIC 31 1 RUNAWAY BUNNY HARPERFESTIVAL
why final queries top 3 rows r different than inner query ?
Is there a seeded function by which I can check all the rows which stored dates in varchar column.
I have a table say test (test_data varchar2(100));
Now I will insert all types of records into the table varchar,number dates and then i will write q query to etch all those records only which has dates only
INSERT INTO test(1); INSERT INTO test('ABC'); INSERT INTO test(SYSDATE); INSERT INTO test(TO_CHAR(SYSDATE,'DD-MON-YYYY')); INSERT INTO test(TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI:SS')); INSERT INTO test('15/01/2012'); ... commit;
I need to create a composite unique index on varchar2, number and CLOB column. I haven't used such index before that have the CLOB column indexing. I found the below link related to CLOB indexing...
[URL]......
Links from where I can get related info. Also I would like to know the impact of such index on performance. I have to store and process around 50 million records in such a way, will it be beneficial to use this index?
I have a table with modifieddate column with 'DATE' data type.I am facing date format exception and tried with to_char, to_date but its throwing invalid number exception. how to format date accordingly.
SELECT * FROM EMP WHERE modifieddate > '31-Dec-2011 18:30';
ORA-01722: invalid number 01722. 00000 - "invalid number"
i am fairly new in the oracle arena, but what would cause a statement such as
ALTER TABLE TEST_TABLE MODIFY text_field1 varchar2(100) DEFAULT 'testval' NULL
to change a column's type from VARCHAR2(100) to VARCHAR2(100 byte)? i found a few mentions of the 100 byte concept online but nothing that jumped out at me.
I am importing the dump.All the tables are getting imported but when it comes to the part as shown in the error it gets struck there and nothing is showed after.
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
The dumps for which I am doing the import is huge. Its around 46 GB.
select sl.sid, sl.serial#, sl.sofar, sl.totalwork from v$session_longops sl, v$session s, dba_datapump_sessions d where s.saddr = d.saddr and s.sid = sl.sid and s.serial# = sl.serial# order by start_time;
It showing the lock for two sid's. Should I kill the process and import the dump again? I used below command to import dums
I have table called INFO and the column called CREATED_DATE . Now the datatype of CREATED_DATE is of varchar2 . Now If I need to query the table through select statement where I need to order the result based on CREATED_DATE , how can i achieve this ?
I have to create a table which should store data at Week level. The table have the following columns
Product id, Loc id, Business group id, FISCAL WEEK , Revenue,
Fiscal week column will have data as '2011-W01', '2011-W47' etc.
What should be the data type for fiscal week column. Based on this table i have to create a calculated column which should fetch trailing 12 weeks average for each row.
if it is possible to assign a varchar2(14) index to a pl/sql table while fetching bulk data with bulk collect.my requirement is to assign varchar2(14) index to a pl/sql table so that i can directly reach to my record by index and process the record further.
further i need to run a loo on this ( for processing each record)my database version is 11.2.01.0.
I have extracted in the following XML document some Mpeg7 visual descriptors from an image and I saved it in an XMLType column. I would like to use XMLQuery to extract the data from the Value node. how write such a query. I could not get the proper Xpath to any node.
I have a task to update one of the rows in a table (having only 2 columns, number and long) which is long data type. We are on Oracle 10g. Not sure how to use update for a long data type column.
I have tried using dbms_metadata_util.long2varchar, but still not getting what I want.
vlanke@tank_db> desc filetable; ID NULL NUMBER(6,0) FILE_CONTENT NULL
I am new to Database field.
- I created a table with 2 columns id (datatype as number) and file_content datatype as BLOB. - My question is under desc filetable; query why does it not show me a data type as BLOB. - create table query does not return any error to me. How do I verify that FILE_CONTENT column has datatype as blob.
I need to get all rows where node <operationStatus> value as SUCCESS. I am running following query but it is returning null value insted of data of columns
SELECT a.MESSAGECONTENTS.extract('/clHeader/msgName/object/msgType/sender/senderInstance/operationStatus/text()').getStringVal() FROM Table_xml_tmp a WHERE a.MESSAGECONTENTS.extract('/clHeader/msgName/object/msgType/sender/senderInstance/operationStatus/text()').getStringVal()= 'SUCCESS'
Now i have a problem which i am facing for the first time. The problem is:
I have created a table test1 with two column of number data type and the column witdth is 25. Then enter the data but when i select the recrod it does not display the column data as it was entered. SQL> create table test1 2 ( 3 startno number(25), 4 endno number(25) 5 );
CREATE TABLE XML_TABLE_1 ( ID NUMBER NOT NULL, SOURCE VARCHAR2(255 CHAR) NOT NULL, XML_TEXT SYS.XMLTYPE, CREATION_DATE TIMESTAMP(6) NOT NULL [code].....
- So HOW do I find the total size occupied by this table. Does BINARY storage work as LOB storage. i.e. I need to consider USER_LOBS as well for this. OR foll. will work
select segment_name as tablename, sum(bytes/ (1024 * 1024 * 1024 )) as tablesize_in_GB From dba_segments where segment_name = 'XML_TABLE_1' and OWNER = 'SCHEMANAME' group by segment_name ;
- Also if I am copying it to another table of same structure as:
Insert /*+ append */ into XML_TABLE_2 Select * from XML_TABLE_1.
Then how much space in ROllbackSegment do I need. Is it equal to the size of the table XML_TABLE_1?
I have existing table which needs to be copy to new table with object using the cursor. The exist table has a rank column which has some duplicate rank, which need to be remove and provide a series of numbers, like 1,2,3,4,5,...
create type UNIVERSITY as object ( U_RANK number(2), U_SCHOOL varchar2(150), U_COUNTRY varchar2(150), U_SCORE number(3) )
I have to change the datatype of a column from CLOB to varchar2, without changing the order of the columns. The table has no data. I could find any other way other than dropping the CLOB columns and then adding new columns with varchar2 datatype. But this changes the order of the columns in the table.
We are working on a performance tuning aspect, where in a table has a LONG datatype and number of round trips are increasing based on the number of rows fetched.i.e one round trip for every row.
Background.
1. created a table with LONG data type. 2. inserted bulk load of data. 3. set auto trace on and executed below tests..
SQL> select count(*) from test_long;
COUNT(*) ---------- 6110
SQL> desc test_long Name Null? Type ----------------------------------------------------------------------------------------------------- -------- ---------------------------------------------------------------------------- ID NUMBER TESTLONG LONG [code].....
but on LONG column, irrespective of the array size the round trips does not reduce.
i have a varchar2 column containing string values that can be converted to date i.e. ('31-JUL-11') and that column also contains text strings in it. i.e. ('Some string data...')
records whose column value can be converted to date are extractable via where clause (i.e. those rows are associated with some fix number / flag)
now when i try to use to_date function i get the error that
" ORA-01858 a non-numeric character was found where a numeric was expected "
in sql i have added a where clause to only pick rows with flag, but even then it gives the error.
using a subquery in the from clause eliminates the error, but when i create it in a view it again gives the same error.