Oracle: Create Table [closed] - oracle

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want to create table and I try did it as following:
And when I try execute this query I get an error

There is a comma missing before "CONSTRAINT". So for Database it seems like you are creating constraint on a column "waktu_selesai" (the last one) whereas you need to create a table-level constraint in order to make this thing work.
create table jadwal(
id_jadwal number generated always as identity primary key,
hari varchar2(10),
waktu_mulai varchar2(5) not null,
waktu_selesai varchar2(5) not null,
constraint jadwal_check_waktu check (to_number(substr(waktu_mulai, 1, 2)) > to_number(substr(waktu_selesai, 1, 2)))
);

Related

Create a column with dollar sign in Oracle SQL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am wondering whether I can create a column with dollar sign? The output should look like the area marked by red line. But the column can still be calculated like number.
I am not sure whether it is capable.
You can try this:
select to_char(500, '$999') from dual
Column-Name with Dollar:
CREATE TABLE t1 (ID int, "$Sal" int);
INSERT INTO t1 values(1,100);
SELECT id, "$Sal" * 10 FROM t1;

ORA-00907: missing right parenthesis, What could be the problem? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I try to add a constraint , but it gave me the error
ORA-00907: missing right parenthesis
What could be the problem?
CREATE TABLE "BDCOMEARE"."PILOTE" (
"matrPlt" INTEGER NOT NULL ,
"nomPlt" VARCHAR2(50) ,
"prenomPlt" VARCHAR2(50) ,
"gradePlt" VARCHAR2(100) ,
"adressePlt" VARCHAR2(100) ,
"salairePlt" NUMBER(10,2) ,
"dateEmbauche" DATE ,
PRIMARY KEY ("matrPlt")
)
ALTER TABLE PILOTE ADD CONSTRAINT check_gradePlt
CHECK (gradePlt IN 'commandantBord', 'assistantBord','officier');
Just that you need brackets after IN clause
CONSTRAINT check_gradePlt CHECK (
gradePlt IN ('commandantBord', 'assistantBord', 'officier')
);

how to find a column name and value of a variable in oracle? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I am not able to find the how to find a column name and value of a variable which is assigned in plsql procedure.
for example:
i_num_XXXX IN NUMBER;
i_str_YYYY IN VARCHAR2;
That would be
select * from user_source where lower(text) like '%i_num_xxxx%'

Oracle pl/sql check if number starts with 9 or 8 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
i am trying to validate data inside my database that is number.
Am i able to detect the retrieved data whether it starts with 8 or 9?
For example:
8999999 is valid
9999999 is valid
7000000 is invalid
Thanks
You can try checking the first character of the field using SUBSTR():
SELECT field_value
FROM your_table
WHERE SUBSTR(TO_CHAR(field_value), 1, 1) IN ('8','9')
The following query will return all records where column data begins with an 8 or 9:
SELECT data
FROM your_table
WHERE REGEXP_LIKE (CAST(data AS varchar2(30)), '^(8|9)(*)');
I assume here that data is a numeric type, and so I cast it to varchar before using REGEXP_LIKE.

How to mask particular column of a table for particular user in Oracle [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Oracle Data masking. How do I mask the data by XXX of a particular column of Table.
RLS policy doesn't work for me.
For security reasons the value is replaced by XXX, so actual value should remain same, and it should be automated for the user
Revoke select on your_table from particular_user;
create view view_on_table as
select col1, col2, 'xxx' as particular_column, col3
from your table;
grant select on view_on_table to particular_user;
:)
Oracle's Virtual Private Database is the only way I know of to make this happen, given your constraint that this must be a direct query against the table: http://www.oracle.com/technetwork/database/security/index-088277.html

Resources