In ORACLE what are the wildcard characters present I want to know ? I have been seeing this tutorial from w3schools and they have listed Wildcard Characters in MS Access and Wildcard Characters in SQL Server.
What about ORACLE?
I have checked ORACLE DOCUMENTATION but there are no wildcard characters present.
If there are wildcard characters present then :
1: What are the equivalent wildcard characters of (^ , #, !) present in ORACLE?
2: How can I use them in ORACLE syntax?
SELECT *
FROM Customers
WHERE City LIKE '[!bsp]%';
What should be the oracle equivalent text of the above code using wildcard ?
You seem to be asking about "wildcard characters" in comparing text strings (as opposed to, for example, the asterisk used in select * from ...). If so: Oracle has the LIKE operator, where the only wildcard characters are percent and underscore, and REGEXP_LIKE (and other regular expression functions) where the wildcard characters are the same as in the POSIX extended regular expression standard.
I have found one solution for the same query in Oracle SQL;
Problem Link: https://www.hackerrank.com/challenges/weather-observation-station-6/problem?h_r=next-challenge&h_v=zen
Question: Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates.
Solution:
SELECT DISTINCT(CITY) FROM STATION WHERE REGEXP_LIKE (CITY,'^(A|E|I|O|U).') ;*
Here's the link where I found a relevant solution.
https://docs.oracle.com/cd/B19306_01/server.102/b14200/conditions007.htm
Related
Running SQL on Oracle through Liquibase and getting error:
ORA-00907: missing right parenthesis
The SQL we're running has double dashes -- which can also represent comments in PLSQL. I'm guessing this is the issue. Should this be escaped somehow?
delete from mytable B where B.NAME in ('XXX--YYY', 'AAA--BBB');
The sequence of the characters --is most likely interpreted as a comment, so the following charactes until the end of the line are ignored.
You may use following workaround, simple splitting the string in two parts
Instead of
'XXX--YYY'
use
'XXX-'||'-YYY'
Do not forget, if you have more dashes, you must repeat stis step , e.g. for --- you must split the string in three part.
Posible similar problem would be for string containing the multiline comment:
'XXX/*YYY', 'XXX*/YYY'
I do find a problem with enconding of characters into Oracle
They are two inverted interrogation characters coming from imported data.
How can i search for two inverted characters into Oracle so i can see how many lines have this problem ?
I assume by "inverted interrogation character" you mean character ¿.
There are two possibilities:
Character ¿ is actually stored in your database, because your database character set (check with SELECT * FROM V$NLS_PARAMETERS WHERE PARAMETER LIKE '%CHARACTERSET') is not capable to support special characters you tried to import.
You can find affected rows with SELECT * FROM TABLE_NAME WHERE REGEXP_LIKE(COL_NAME, '¿');
Your client (e.g. SQL*Plus) is not able to display the special character and substitute those by placeholder ¿. In this case set your NLS_LANG value properly, see this answer for more details.
Unfortunately you did not tell us how you imported your data nor any of your characters sets. Thus I cannot provide you a guideline to set NLS_LANG properly.
I have a schema in which a small number of the thousands of stored procedures have been created with quoted identifiers. I need to fix them. The only way I currently have of identifying them is by opening them up in SQLDeveloper, one at a time, and checking to see if the CREATE OR REPLACE... bit at the top has quotes around the procedure name. Does anyone have any cunning method of identifying these troublesome objects more easily? Have I overlooked some Oracle system view with a this_uses_quoted_identifiers flag, perhaps? Please enlighten me!
There are at least 2 ways:
select * from all_source where type = 'PROCEDURE' and line = 1 and text like '%"%'
and
select * from all_procedures where procedure_name != upper(procedure_name)
However, none of them is 100% correct and complete. The first one looks for any double quote in the first line. The second one would only find procedures with lower caps in their name which would mean that double quotes have been used.
As far as I know, if you quote an identifier, but all the letters are in capital form, it is just equivalent to non quoted identifier.
So you can select from ALL_OBJECTS to see which object names have names with non capital letters.
I have a little silly question. I have installed a PostgreSQL DB Server, but when I run query, there is a problem with column identifier without quotes. I don't know why the quotes around identifiers are needed. My query:
SELECT vc."CAR_ID"
FROM "VEL_CAR" vc, "VEL_DRIVER" vd, "VEL_DRIVER_CAR" vdc
WHERE vc."CAR_ID" = vdc."CAR_ID" and
vdc."DRIVER_ID" = vd."DRIVER_ID";
My practice from Oracle DB is not to use ". So in Oracle:
SELECT vc.CAR_ID
FROM VEL_CAR vc, VEL_DRIVER vd, VEL_DRIVER_CAR vdc
WHERE vc.CAR_ID = vdc.CAR_ID and
vdc.DRIVER_ID = vd.DRIVER_ID;
When I run this query without quotes in PostgreSQL it throws error about syntax:
ERROR: column vc.car_id does not exist
LINE 1: SELECT vc.CAR_ID
Do you know why?
--SOLVED--
Thank you, now I solved the problem! It was about table creation. I created table objects using pgAdminIII and i wrote table name and column names uppercased. pgAdminIII created query with quotas - because of the names was uppercased. So query had to be written with quotas.
When you create your tables using double quotes, column and table names become case sensitive. So "car_id" is a different name than "CAR_ID"
You need to create your tables without using double quotes, then the names are not case sensitive: car_id is the same as CAR_ID (note the missing quotes!)
See the manual for details:
http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
Edit:
Oracle behaves just the same way. The only difference is that Oracle stores names in upper case and Postgres stores them in lower case. But the behaviour when using quotes is identical.
From Postgres documentation :
Quoting an identifier also makes it case-sensitive, whereas unquoted names are always folded to lower case. For example, the identifiers FOO, foo, and "foo" are considered the same by PostgreSQL, but "Foo" and "FOO" are different from these three and each other. (The folding of unquoted names to lower case in PostgreSQL is incompatible with the SQL standard, which says that unquoted names should be folded to upper case. Thus, foo should be equivalent to "FOO" not "foo" according to the standard. If you want to write portable applications you are advised to always quote a particular name or never quote it.)
Seems to me that the table vc does not have a column named car_id. Are you sure it is there? Do \d vel_car to see the structure of the table.
The quotes are optional and you can usually skip them.
I am using the QOCI binding to connect Qt with an Oracle 10g database. The code is really simple:
QSQLQuery sqlQuery = QSQLQuery(database);
sqlquery.prepare(querystring);
sqlQuery.exec();
Now if querystring is only one line, it works:
select * from dual
But if it contains multiple lines, I get an ORA-911 invalid character:
select *
from dual
I have a lot of queries spanning multiple lines, so this is quite a problem. Just removing newlines in Qt is not an option, because the queries contain end-of-line comments ("--").
Any suggestions how I can execute these multi-line queries?
Answering my own question: The newline character was the unicode U+2029 paragraph seperator instead of a normal newline (\n). This triggered the ORA-911.
querystring.replace(QChar(0x2029), QChar('\n'));
does the trick.