I have a table structure as follows Student(Id,First_Name, Last_Name, email, Contact, Address1 ,Address2, City, Edit_Date,Create_Date,Archived)
Now if there is more than one row with same email the one with the latest edit date should be updated with missing fields by using same field value other rows (if the field is present in more than one row, the one with the next latest edit date is to be considered) and
the archived status of all rows with same email except this master row must be set to 1.The Create_Date must be set to the minimum of all the create_date values of rows with same email value
This calculates the difference between a set date and a contact date, I only want it to return the minimum of the results set for each patient, how can this be achieved? At the moment it pulls off several records for each patient as there are several contacts.
i am trying to enable flashback on in my database and i am getting the below error.
idle> alter database flashback on; alter database flashback on * ERROR at line 1: ORA-38706: Cannot turn on FLASHBACK DATABASE logging. ORA-38708: not enough space for first flashback database log file
my db_recovery_file_dest_size is 1g. If i change it to 20g i am able to "alter database flashback on".
Why does a size of 1g give this proble? Any simple steps or recommendation that i am missing? Or is the size of the DB which impacts the db_recovery_file_dest_size also?
idle> select *from v$version;
BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production PL/SQL Release 11.1.0.7.0 - Production CORE 11.1.0.7.0 Production TNS for Linux: Version 11.1.0.7.0 - Production NLSRTL Version 11.1.0.7.0 - Production
I am trying to find out what is the minimum Oracle User Role required for the GetSchema command to work using ODP.NET and the Oracle.DataAccess library.
Dim cn As New OracleConnection(ConnectionString) 'Oracle.DataAccess.Client.OracleConnection Return cn.GetSchema("Tables")
concept of composite and candidate keys. i have gone through all the definition part but did not understand the concept of creating candidate key for example:-
I am trying write a script that will return all values (based on the minimum tarif) from the Germany table for any duplicate values. Duplicate values are any values with the same UFI, ZC,limitid,depot. The German table also contains the fields tarif, city, supplier, etc.
Below is the script I have previously used to sort out duplicates. I have tried 50 different ways get it to return just lines for the minimum tariff but haven't been successful.
select * from Germany t where (ufi,zc,limitid,depot) in ( select ufi,zc,limitid,depot from ( select ufi,zc,limitid,depot, count(*) n from Germany t group by ufi,zc,limitid,depot) where n<>1 )
The above result give me minimum salary but total number of JOB holders, You can see only one SALEMAN getting 1000 but count show total number of SALESMAN. Similarly 3 MANAGERS are getting minimum and same salary but count show total number of MANAGERS.
My question is how can i get number of person on min salary?
I have the following 3 columns in my VERSIONS table.
MAJOR MINOR MICRO
The MAJOR,MINOR and MICRO columns create a unique composite primary key. I need to query out the last version by doing the following 3 queries and combine them.
select max(major) as max_major from versions select max(minor) as max_minor from versions where major = :max_major select max(micro) as max_micro from versions where minor = max_minor and major = max_major
Is there any way I can query out max(major),max(minor),max(micro) in a single query.
I have a lot of queries on a table with WHERE clause:
WHERE CR_DATE > :y AND CR_VALUE = :x
Actually, there is an index on (CR_DATE) but much more selective index is on (CR_DATE, CR_VALUE). If I do not UPDATE any records on this table, is there any difference in INSERT operation (or another problem) when I replace actual index with multi-column index?
I am following Lynda Tutorial for Normalization. I have understand normalization.The core concept of primary key is that it uniquely identifies each record in the table, but here in the given below image the 'COURSE' field is repeating 'SQL101' value again and again but still the teacher in the video is calling it primary key and combination of date & Course column Composite key.how can a field which vales are repeating can be called as Primary Key?
I am replacing a composite PK with a new single PK as business changed. I am creating sequence to fill the new field that should present the PK but I need to fill it according to the values of the old composite PK.
I need to update ABC and set ABC_SERIAL = SEQ_ABC.nextval but i need this to be done according to the order of the old composite primary key... i.e. rows with COMP_PK1 = 1 are filled before rows with COMP_PK1 = 2 and so on..
I have to create six tables as part of my assignment. I have created 5 tables. I am having trouble with the 6th. How can I reference a foreign key to a composite primary key? I have colored red the areas that I think are giving me trouble which is in the 6th table, the Registration Table.
Create Table Student ( StudentID number (6,0) NOT NULL, Student_Name varchar2 (20) NOT NULL, Constraint Student_PK Primary Key (StudentID) );
Create Table Faculty ( FacultyID number (5,0) NOT NULL, Faculty_Name varchar2 (20) NOT NULL, Constraint Faculty_PK Primary Key (FacultyID) );
Create Table Course ( CourseID varchar2 (10) NOT NULL, Course_Name varchar2 (20) NOT NULL, Constraint Course_PK Primary Key (CourseID) );
Error starting at line 1 in command: Create Table Registration ( StudentID number (6,0) NOT NULL, Section_No number (5,0) NOT NULL, Semester varchar2 (7) NOT NULL, Constraint Registration_PK Primary Key (StudentID, Section_No, Semester), Constraint Registration_FK1 Foreign Key (StudentID) references Student (StudentID), Constraint Registration_FK2 Foreign Key (Section_No) references Section (Section_No, Semester, CourseID), Constraint Registration_FK3 Foreign Key (Semester) references Section (Section_No, Semester, CourseID) )
Error at Command Line:8 Column:104 Error report: SQL Error: ORA-02256: number of referencing columns must match referenced columns 02256. 00000 - "number of referencing columns must match referenced columns" *Cause: The number of columns in the foreign-key referencing list is not equal to the number of columns in the referenced list. *Action: Make sure that the referencing columns match the referenced columns.
what are the minimum files which are required to open the db ? take it as this
I have oracle installed in c drive. I have placed 3 datafile related to one tablespace say test: two in D and one in E. I have place 3 datafile related to tablespace say orcl : two in D and one in E.
my undo is in E scenario is that my E drive crashed . db is in no archive mode . no backup is there. to be more worst db shuts down abnormally. I want my db open with data of c drive and D drive.
Here the GROUP is changing when the data type is changing and thus for same data type the group shall remain the same As of now this is achieved by - first selecting distinct object_type, then it's mod(rownum,<input variable) and this result of 'mod' is doing the grouping which is the retrieved along with rowid of all individual record
Present query is as following and it is not much efficient
SELECT DO.ROWID RWID, RID FROM DO, ( SELECT OT,CASE MOD(ROWNUM,:v) WHEN 0 THEN :v ELSE MOD(ROWNUM,:v) end as RID FROM( (SELECT DISTINCT OBJECT_TYPE OT
[code]....
I tried using sequence with cycle but it gave different results. Even I tried following but it did not gave satisfactory results
select d.rowid,d.object_type,x.x1 from do d,(select distinct object_type,mod(rownum,:v) x1 from do where created>'01-jan-2008')x where d.object_type=x.object_type and created>'01-jan-2008';
In short the query needs Distinct with mod(rownum) and individual records in a single pass The mod(rownum) i.e. group shall change when the object_type changes but then shall remain constant through out the particular object_type.
I have an employee table which has a primary key and a self referencing foreign key, as shown here
create table employee ( id not null, name not null, department not null, supervisor_id not null ,constraint constraint_1 primary key (id) ,constraint constraint_2 foreign key (supervisor_id) references employee (id));
Now if i make the primary key composite, as shown below -
create table employee ( id not null, name not null, department not null, supervisor_id not null ,constraint constraint_1 primary key (id, name) ,constraint constraint_2 foreign key (supervisor_id) references employee (id));
Oracle is throwing the following error -
ORA-02270: no matching unique or primary key for this column-list
How can this error be fixed without changing the composite primary key?
I'm trying to group sets of data based on time separations between records and then count how many records are in each group.
In the example below, I want to return the count for each group of data, so Group 1=5, Group 2=5 and Group 3=5
SELECT AREA_ID AS "AREA ID", LOC_ID AS "LOCATION ID", TEST_DATE AS "DATE", TEST_TIME AS "TIME" FROM MON_TEST_MASTER WHERE AREA_ID =89 AND LOC_ID ='3015' AND TEST_DATE ='10/19/1994';
[code]....
Group 1 = 8:00:22 to 8:41:22
Group 2 = 11:35:47 to 11:35:47
Group 3 = 15:13:46 to 15:13:46
Keep in mind the times will always change, and sometime go over the one hour mark, but no group will have more then a one hour separation between records.
I am trying to restore to a backup instance on a backup server. When I try to recreate the tables I keep getting ORA-01659: unable to allocate MINEXTENTS. The tablespaces and datafiles on both servers show as the same size in OEM.
I have dropped all tables and OEM shows tablespaces are empty. Then I run a script to recreate all tables. Most of the tables don't get created because their TS is full. After the script to recreate all tables runs, the main tablespaces are full, more full than on the production machine. I have also tried ALTER TABLESPACE xxx COALESCE; on each tablespace right after dropping all tables and before recreating them to reclaim free space. Why is it full? I've only dropped and created the tables, there shouldn't be any data in them yet.
ORA-01659: unable to allocate MINEXTENTS beyond 2 in tablespace PLUS_T...The backup instance was already there, all I did was drop the tables. Here's what I ran on prod to build a script to recreate the tables on backup server. Got it off Burleson somewhere.
SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name) ||'; ' FROM USER_TABLES u;
emp_id number, name varchar2(30), from_dt date, remarks varchar2(60)
insert into MY_TAB values (1,'TOM','01-JAN-13', 'some remark'); insert into MY_TAB values (1,'TOM','02-JAN-13', 'some remark'); insert into MY_TAB values (2,'TOM','01-JAN-13', 'some remark'); insert into MY_TAB values (3,'TOM','01-JAN-13', 'some remark'); insert into MY_TAB values (4,'TOM','01-JAN-13', 'some remark'); insert into MY_TAB values (4,'TOM','02-JAN-13', 'some remark');
How do I ensure that when a user tries to insert record with emp_id as 1, then he should only be allowed to enter another from_dt but the value in the name column have to be the same as in the previous row of emp_id 1.
insert into MY_TAB values (1,'TOOM','03-JAN-13') --shld not be allowed.
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 Want to tune the attached query. I have tried by creating the normal indexes and composite indexes on the fields . I feel that , Only normal index is required for this instead of composite index?
I read that rownum is applied after the selection is made and before "order by". So, in order to get the sum of salaries for all employees in all departments with a row number starting from 1, i wrote :
select ROWNUM,department_id,sum(salary) from employees group by department_id
If i remove rownum, it gives the correct output. Why can't rownum be used here ?
The blocksize for my database is 4096, as i have heard that the minimum size of the datafile is decided by blocksize, but i want to know that how it is calculated as by giving the above syntax the other values will be default. I am trying the syntax in oracle 9.2.0.1.0 version.
I have created an non unique index lk_fein on lookup_fein( code,map_id,trash). When I check the explain plan it does a full table scan on lookup_fein. if I force it to use index by it does and the cost also decreases.