Constraint against duplication

how can i make a constraint on a varchar2 column to prohibit the duplication of data in its rows , although itsnt a primary key in the table ?!

Hi
Yes, you can! Define a unique key on that column
Example of table creation:
-- Create table
create table TEST
  COL1 NUMBER not null,
  COL2 VARCHAR2(30)
tablespace USERS
  pctfree 10
  initrans 1
  maxtrans 255
  storage
    initial 64K
    minextents 1
    maxextents unlimited
-- Create/Recreate primary, unique and foreign key constraints
alter table TEST
  add constraint PK_TEST primary key (COL1)
  using index
  tablespace USERS
  pctfree 10
  initrans 2
  maxtrans 255
  storage
    initial 64K
    minextents 1
    maxextents unlimited
alter table TEST
  add constraint UK_TEST unique (COL2)
  using index
  tablespace USERS
  pctfree 10
  initrans 2
  maxtrans 255
  storage
    initial 64K
    minextents 1
    maxextents unlimited
  );Example:
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL> desc test;
Name Type         Nullable Default Comments
COL1 NUMBER                                
COL2 VARCHAR2(30) Y                        
SQL> select * from user_constraints uc where uc.table_name = 'TEST';
OWNER                          CONSTRAINT_NAME                CONSTRAINT_TYPE TABLE_NAME                     SEARCH_CONDITION                                                                 R_OWNER                        R_CONSTRAINT_NAME              DELETE_RULE STATUS   DEFERRABLE     DEFERRED  VALIDATED     GENERATED      BAD RELY LAST_CHANGE INDEX_OWNER                    INDEX_NAME                     INVALID VIEW_RELATED
HR                             PK_TEST                        P               TEST                                                                                                                                                                                      ENABLED  NOT DEFERRABLE IMMEDIATE VALIDATED     USER NAME               15/03/2009  HR                             PK_TEST                               
HR                             UK_TEST                        U               TEST                                                                                                                                                                                      ENABLED  NOT DEFERRABLE IMMEDIATE VALIDATED     USER NAME               15/03/2009  HR                             UK_TEST                               
SQL> insert into test(col1, col2) values (1, 'john');
1 row inserted
SQL> insert into test(col1, col2) values (2, 'john');
insert into test(col1, col2) values (2, 'john')
ORA-00001: unique constraint (HR.UK_TEST) violated
SQL> Regards,

Similar Messages

  • Question about how to create FORIGEN KEY constraints against XMLTYPE table

    Hi,
    1.I have a table called SNPLEX_DESIGN which is created as XMLTYPE, the XMLTYPE is refered to a registered XMLschema. The XMLschema has a data element called BATCH_ID, and I create a primary key for the SNPLEX_DESIGN table on the BATCH_ID. The SQL staement as
    ALTER TABLE SNPLEX.SNPLEX_DESIGN ADD (CONSTRAINT "BATCH_ID_PK" PRIMARY KEY(xmldata."BATCH_ID"))
    2. I have another table call SNPLEX_PROCESS which is a regual relational table with a column TOKENID. I would like to create a forign key on TOKENID which needs to refer to the SNPLEX_DESIGN table BATCH_ID_PK primary key.
    But I got error when I try to alter the SNPLEX_PROCESS table.
    SQL> ALTER TABLE "SNPLEX"."SNPLEX_PROCESS" ADD (CONSTRAINT "BATCH_ID_FK" FOREIGN KEY("TOKENID") RE
    FERENCES "SNPLEX"."SNPLEX_DESIGN"(xmldata."BATCH_ID"));
    ERROR at line 1:
    ORA-02298: cannot validate (SNPLEX.BATCH_ID_FK) - parent keys not found
    3. Can someone helps me on this.. I have no problem to create a foreign key in SNPLEX_DESIGN to refere primary key in relational table. But Why I can not do the other way around.
    Any assistances will be appreciated..
    Jinsen

    Hi Jinsen
    As mentioned in the error message not all rows in PROCESS have a corresponding value in DESIGN.
    To find out which are missing do some selects to compare your data or use the exception clause in the ALTER TABLE statement.
    e.g.: ALTER TABLE "SNPLEX"."SNPLEX_PROCESS" ADD (CONSTRAINT "BATCH_ID_FK" FOREIGN KEY("TOKENID") RE
    FERENCES "SNPLEX"."SNPLEX_DESIGN"(xmldata."BATCH_ID")) EXCEPTIONS INTO <exception table>
    Notice that you have to create the <exception table> with the script $ORACLE_HOME/rdbms/admin/utlexcpt.sql.
    Chris

  • Check constraint/foreign key combination

    I would like to add a constraint (check, FK, or otherwise) that forces a value to be either -1 OR be in a foreign table.  The statement below is invalid because you can't use subqueries, but I think it's clear what I'm trying to do.  Can anyone
    suggest a different approach?
    Thanks!
    ALTER TABLE cfg.ClientFieldThreshold ADD CONSTRAINT CK_cfg_ClientFieldThreshold_DBListID
    CHECK (DBListID = -1 OR DBListID IN (SELECT ID FROM dbo.vwClientDatabases)
    /* the subquery here isn't allowed */

    3 ways to do this. 
    1) use NULL instead of -1 as the value that does not have to be in the foreign table.  Then you just need a normal foreign key (because a foreign key column that contains NULL is not checked against the foreign table.  Sample code to do this
    Create Table FooParent(ParentID int primary key);
    Create Table FooChild(ChildId int primary key, ParentID int Null, Constraint FooChildFK Foreign Key(ParentID) References FooParent);
    go
    -- Can add row with NULL
    Insert FooChild(ChildId, ParentID) Values (1, Null);
    go
    -- But cannot add row with any other value that is not in FooParent
    Insert FooChild(ChildId, ParentID) Values (2, 25);
    go
    -- Check result
    Select * From FooChild;
    go
    Drop Table FooChild;
    go
    Drop Table FooParent;
    2) Add a dummy row to the parent table with a primary key of -1.  Then, of course, all you need is a foreign key constraint.
    3) Add a persisted computed column that is NULL whenever your column that you want to enforce the constraint against is equal to -1, otherwise just the value in that column.  Then create a foreign key on the computed column.  Sample code
    Create Table FooParent(ParentID int primary key);
    Create Table FooChild(ChildId int primary key, ParentID int Not Null, AlteredParentID As NULLIF(ParentID, -1) Persisted, Constraint FooChildFK Foreign Key(AlteredParentID) References FooParent);
    go
    -- Can add row with -1
    Insert FooChild(ChildId, ParentID) Values (1, -1);
    go
    -- But cannot add row with any other value that is not in FooParent
    Insert FooChild(ChildId, ParentID) Values (2, 25);
    go
    -- Check result
    Select * From FooChild;
    go
    Drop Table FooChild;
    go
    Drop Table FooParent;
    Tom

  • Constraints store in the database............

    Can someone tell me that in which form the constraints store in the database ,are they store in form of pcode or something else

    To find out constraints against the table , you need to fire .
    sql > select table_name , constraint_name , constraint_type
    from user_constraint ;
    Hare Krishna
    Alok

  • TIPS(30) : TABLE에 걸려 있는 CONSTRAINT 찾아 보기

    제품 : SQL*PLUS
    작성날짜 : 1996-12-27
    TIPS(30) : TABLE에 걸려 있는 CONSTRAINT 찾아 보기
    ================================================
    REM Script:
    REM tbconst.sql
    REM
    REM
    REM NOTE * Need select access against sys.dba_cons_columns and
    REM sys.dba_constraints to run this.
    REM
    REM Parameter:
    REM owner = owner of the table
    REM table = name of table to report on
    REM
    REM Usage:
    REM SQL> @tbconst.sql
    REM
    REM Oracle Version:
    REM Tested on Version 7.1.4 as a dba user
    REM Tested on Version 7.2.3 as user sys
    REM
    /* Capture owner and table name parameters
    def owner = &&1
    def table_name = &&2
    /* Define working variables
    def gScript = 'tbconst.sql'
    def gTitle = 'Constraints against table &owner..&table_name'
    /* Set the system variables
    set concat on
    set echo off
    set embedded off
    set pagesize 58
    set showmode off
    set space 1
    set termout on
    set trimout on
    set verify off
    set wrap on
    /* Get today's date
    set termout off
    col today new_value now noprint
    select to_char(sysdate, 'DD Mon YYYY HH:MIam') today
    from dual;
    /* Get the name of the database
    col dbname new_value sid noprint
    select name dbname
    from v$database;
    /* Set the report title based on the information gathered and passed
    clear breaks
    set termout on
    set heading on
    ttitle -
    left 'Database: &sid' right now skip 0 -
    left ' Report: &gScript' right 'Page ' sql.pno skip 2 -
    center '&gTitle' skip 2
    set newpage 0
    /* Run the Report
    set linesize 80
    set arraysize 1
    create or replace package mitconstraint as
    function mit$getcols ( cn_name in varchar2,
    cn_owner in varchar2,
    tb_name in varchar2)
    return varchar2;
    pragma restrict_references (mit$getcols, WNDS,WNPS);
    function mit$getdesc ( cn_name in varchar2,
    cn_owner in varchar2,
    tb_name in varchar2)
    return varchar2;
    pragma restrict_references (mit$getdesc, WNDS,WNPS);
    end mitconstraint;
    create or replace package body mitconstraint as
    function mit$getcols (
    cn_name in varchar2,
    cn_owner in varchar2,
    tb_name in varchar2)
    return varchar2
    as
    val varchar2(500);
    col_name varchar2(30);
    found boolean;
    cursor c1 is
    select column_name
    from sys.dba_cons_columns
    where constraint_name = upper(cn_name) and
    owner = upper(cn_owner) and
    table_name = upper(tb_name);
    Begin
    val := '';
    found := FALSE;
    for record in c1 Loop
    if found = FALSE then
    found := TRUE;
    else
    val := val ||', ';
    end if;
    val := val || record.column_name;
    end loop;
    return val;
    end mit$getcols;
    function mit$getdesc (
    cn_name in varchar2,
    cn_owner in varchar2,
    tb_name in varchar2)
    return varchar2
    as
    cn_type char(1);
    descr varchar2(2000);
    found boolean;
    cursor c1 is
    select owner || '.' || table_name val
    from sys.dba_constraints
    where r_owner = upper(cn_owner) and
    r_constraint_name = upper(cn_name);
    begin
    found := FALSE;
    descr := '';
    select constraint_type
    into cn_type
    from sys.dba_constraints
    where constraint_name = upper(cn_name) and
    owner = upper(cn_owner) and
    table_name = upper(tb_name);
    if cn_type = 'U' then
    descr := ' ';
    else if cn_type = 'P' then
    descr := 'Referenced by: ';
    for record in c1 loop
    if found = FALSE then
    found := TRUE;
    else
    descr := descr || ', ';
    end if;
    descr := descr || record.val;
    end loop;
    else if cn_type = 'R' then
    select 'References ' || b.owner || '.' || b.table_name
    into descr
    from dba_constraints a,
    dba_constraints b
    where a.table_name = upper(tb_name) and
    a.owner = upper(cn_owner) and
    a.constraint_name = upper(cn_name) and
    b.owner = a.r_owner and
    b.constraint_name = a.r_constraint_name;
    else if cn_type = 'C' then
    select search_condition
    into descr
    from dba_constraints
    where
    constraint_name = upper(cn_name) and
    owner = upper(cn_owner) and
    table_name = upper(tb_name);
    descr := ltrim(descr);
    else
    descr := ' ';
    end if;
    end if;
    end if;
    end if;
    return descr;
    end mit$getdesc;
    end mitconstraint;
    col constraint_name format a12 heading 'Constraint|Name'
    col type format a11 heading 'Type'
    col cols format a21 heading 'Columns'
    col des format a33 heading 'Description'
    select constraint_name,
    'Primary Key' type,
    mitconstraint.mit$getcols(constraint_name,'&owner','&table_name') cols,
    mitconstraint.mit$getdesc(constraint_name,'&owner','&table_name') des
    from dba_constraints
    where owner=upper('&owner') and
    table_name = upper('&table_name') and
    constraint_type = 'P'
    union
    select constraint_name,
    'Referential' type,
    mitconstraint.mit$getcols(constraint_name,'&owner','&table_name') cols,
    mitconstraint.mit$getdesc(constraint_name,'&owner','&table_name') des
    from dba_constraints
    where owner=upper('&owner') and
    table_name =upper('&table_name') and
    constraint_type = 'R'
    union
    select constraint_name,
    'Table Check' type,
    mitconstraint.mit$getcols(constraint_name,'&owner','&table_name') cols,
    mitconstraint.mit$getdesc(constraint_name,'&owner','&table_name') des
    from dba_constraints
    where owner=upper('&owner') and
    table_name = upper('&table_name') and
    constraint_type = 'C'
    union
    select constraint_name,
    'View Check' type,
    mitconstraint.mit$getcols(constraint_name,'&owner','&table_name') cols,
    mitconstraint.mit$getdesc(constraint_name,'&owner','&table_name') des
    from dba_constraints
    where owner=upper('&owner') and
    table_name = upper('&table_name') and
    constraint_type = 'V'
    union
    select constraint_name,
    'Unique' type,
    mitconstraint.mit$getcols(constraint_name,'&owner','&table_name') cols,
    mitconstraint.mit$getdesc(constraint_name,'&owner','&table_name') des
    from dba_constraints
    where owner=upper('&owner') and
    table_name = upper('&table_name') and
    constraint_type = 'U'
    order by 2,1
    drop package mitconstraint;
    /* Clear variables
    undefine 1
    undefine 2
    undefine owner
    undefine table_name
    undefine gScript
    undefine gTitle
    ttitle off
    btitle off
    clear column
    clear breaks
    /* End of Script
    */

  • Constraints with Excel

    Is it possible to use constraints with an Excel source? I have defined a constraint on the source table, and if I open the constraint, go to the control tab, and click 'check', it shows 1 row not satisfying the constraint. However, when I execute my interface, there are no error rows.
    Also - if I run Control->Check on my source table, I get the error message: com.sunopsis.tools.core.exception.SnpsSimpleMessageException: CKM not selected.
    I do not know how (or if it's possible) to select a CKM for a specific source table.
    Is the only way to run constraints against an Excel source to use an intermediate staging table?

    What about this?
    SQL> drop table tesst;
    Table dropped.
    SQL> create table tesst(
      2  a  varchar2(2),
      3  b  varchar2(2),
      4  check((a not in ('A','B','C') and b is not null) or
      5        (a in ('A','B','C') and b is null)));
    Table created.
    SQL> insert into tesst values('A',null);
    1 row created.
    SQL> insert into tesst values('B',null);
    1 row created.
    SQL> insert into tesst values('K',null);
    insert into tesst values('K',null)
    ERROR at line 1:
    ORA-02290: check constraint (HR.SYS_C003056) violated
    SQL> insert into tesst values('B',null);
    1 row created.
    SQL> insert into tesst values('K','Y');
    1 row created.
    SQL> insert into tesst values('H','M');
    1 row created.
    SQL> insert into tesst values('B','M');
    insert into tesst values('B','M')
    ERROR at line 1:
    ORA-02290: check constraint (HR.SYS_C003056) violated

  • Help with a check constraint

    I have inadvertantly posted this in the wrong section, so I am reposting this in the SQL section and marking this one as answered.
    Hi,
    I have a question regarding creating a constraint against two tables. I have an FK in table_A that should check the constraint against two related tables. Table_A is the table that holds the FK and tables B and C hold the PK back to table A. The problem is with my constraint FK I receive the message ORA-02251: subquery not allowed here. I need to ensure that the AFK contains the FK value that is in either TABLE_B or TABLE_C .
    In my create statement I have
    CREATE TABLE TABLE_A
         (_PK INTEGER NOT NULL ENABLE,
         _FK INTEGER NOT NULL ENABLE,
         CONSTRAINT A__PK PRIMARY KEY (_PK) ENABLE,
         CONSTRAINT A__FK CHECK (_FK IN (SELECT FK FROM TABLEB UNION SELECT FK FROM TABLEC)) ENABLE
    Thanks
    Edited by: user11947229 on Oct 10, 2009 11:43 AM

    "FK value that is in either TABLE_B or TABLE_C"
    This is exactly what is not constraint! Constraint is against one object not set of objects like in your case.

  • Downloading photos from email to iphoto

    I have downloaded photos from an email in gmail (all .jpg) and they are in finder (actually in the iphoto file) and will open in preview, but I cannot transfer to iphoto library. I am using iphoto 6.06, OS 10.4.1. I get the message: unreadable files, the files could not be imported.

    kezar
    Welcome to the Apple Discussions.
    iPhoto is a database, and like any db, data must be imported into it. So putting it in the iPhoto Library Folder is not the way to do it. You should never do anything in there - there are no user serviceable parts there.
    iPhoto will not import pics in the active iPhoto Library Folder as a sensible precaution against duplication.
    So, move the file to the desktop and import from there.
    Regards
    TD

  • Can't import JPGs but I can open with Preview

    iPhoto 4, OSX 10.3.9
    I copied hundreds of JPGs (from XP) to OSX and tried to import them into iPhoto. I get an error message.
    "Unreadable Files
    The following files could not be imported (they may be an unrecognized file type of the files may not contain valid data).
    If I open the image with Preview and then save it as a JPG, I can import it, however it is impractical to do this with the volume of images I have. Is this a known issue? Are there any workarounds?

    Just about anywhere else...
    iPhoto is a database and will import the pics to the iPhoto Library Folder when you add them to the library. It will not import pics from the iPhoto Library Folder as a protection against duplication. So, put the pics on the desktop, import them and trash the files from the desktop when you're finished.
    Regards
    TD

  • Can't import pictures I once could  Unrecognized file type

    I recently had to reinstall some system software because my computer wouldn't reboot. When I opened up iPhoto 5 nothing was there. I went to a back up and imported the latest Librarty. When I went to import the rest of the photos I got this error message... "The following files could not be imported (they may be an unrecognized file type or the files may not contain vallid data)." All my pictures are the same file type and size and come from the same camera. They all open in the Preview application.

    Diane
    Are they in the iPhoto Library Folder? Because iPhoto wont import pics from the iPhoto Library Folder - a precaution against duplication. Drag them to the desktop and try again.
    Regards
    TD

  • Can't import photos from another machine???

    I have downloaded a few albums on another machine and then brought a copy home to put on my iPhoto library but every time I try to import I get an error message saying:
    '+The following files could not be imported (they may be an unrecognized file type or the files may not contain valid data).+'
    All the images are in Jpeg format!

    they are in my iPhoto Library
    How did they get there? iPhoto will not import pics from the active iPhoto Library Folder - a protection against duplication. There is never a need for the user to enter that folder and anytime you do you risk damaging your Library.
    Regards
    TD

  • Skip Level Dimensions

    Dear all
    We have a client with an interesting problem. I was wondering if the group could offer any feedback on this design question, where we think it involves a concept called 'skip levels'. The client is using Oracle 9.0.2 with their data mart cube held as ROLAP. Our first thoughts are that what they want to do is better served by using a true OLAP tool such as Oracle Express, or Oracle 9i OLAP, which deals with skip level dimensions easier. Anyway, here's the problem :
    "For our warehouse project, we need some dimensions (initially: account, company) that use a skip level hierarchy. This means that the lowest level dimensions are of the same level (G/L account or company) and they need to roll up in a structure of varying levels, before they come together again in a highest level.
    Ideally, we would like to use a data structure that can be used transparently by the user and allows for rollups of amounts through the dimension. We would like to be able to populate the dimension through OWB and to query the data using both Crystal reports v9 and BI beans and possibly other tools that recognize the Oracle data warehouse concept.
    The two solutions we are aware of are:
    1.     Insert Dummy levels:
    This is not a nice solution but is will work and it is simple.
    2.     Insert a helper table that contains the higher level account with all the children (as per Ralph Kimball)
    This seems a cumbersome solution but I am sure it would work also. The question is how the Oracle's BI beans and the CWM2 metadata would recognize this and how we can make this transparent to the user.
    I am sure there are other solutions to the problem. It seems like the problem would be solved by the next release of Oracle (9.0.3?), which allows us to deal with skip level hierarchies through CWM2 (which I believe this is). The solution we choose should also allow us to easily upgrade to the new skip level hierarchy, which I would expect to be easier to use then the above."
    The main thing to bear in mind here is that they want to implement a ROLAP solution, using Oracle 9i tables, dimensions and heirarchies. It also has to work with Oracle Warehouse Builder, take advantage of the CWM2 metadata (if possible) and work with the BI Beans.
    Any thoughts on this? Does anyone know how Oracle are going to cater for skip-level dimensions with the next release? Is this through the improved support for the CWM2 metadata standard for ROLAP cubes, or is the customer best of going to the true OLAP 'Analytic Workspace'? If we ignore a MOLAP solution, what's the best way of dealing with this, in such a manner that it's transparent to query tools, and isn't too much of a 'hack'?
    Many thanks in advance,
    Mark Rittman
    Mark Rittman
    Consulting Manager, Plus Consultancy
    [email protected]
    [email protected]--------------

    As part of my search i've uncovered an article by Ralph Kimball on using 'helper tables' to deal with ragged hierarchies.
    http://www.dbmsmag.com/9809d05.html
    This advocates using a table between the fact table and the dimension. Quoting from Mr. Kimball;
    "You can solve this modeling problem by inserting a helper table between the dimension table and the fact table, as shown in Figure 3 (http://www.dbmsmag.com/9809d05.html#fig3). Amazingly enough, you don't have to make any changes to either the dimension table or the fact table; you just rip the join apart and insert the helper table.
    The helper table contains one record for each separate path from each node in the organization tree to itself and to every node below it. There are, then, more records in the helper table than there are nodes in the tree. In Figure 3 we need a total of 43 records in the helper table. See if you can work this out.
    Each record in the helper table contains the fields:
    - Parent Customer Key
    - Subsidiary Customer Key
    - Depth From Parent
    - Lowest Flag
    - Topmost Flag.
    If you are descending the tree from certain selected parents to various subsidiaries, you join the dimension table to the helper table and the helper table to the fact table with the joins as shown in Figure 3. The Depth From Parent field counts how many levels the subsidiary is below the parent. The Lowest Flag field is True only if the subsidiary has no further nodes beneath it. The Topmost Flag field is True only if the parent has no further nodes above it.
    The beauty of this design is that you can place any normal dimensional constraint against the Customer dimension table and the helper table will cause all the fact table records for the directly constrained customers plus all their subsidiaries to be correctly summarized. In other words, you can use your standard relational databases and your standard query tools to analyze the hierarchical structure."
    My question is - has anyone tried to implement this with OWB, or with the Oracle ROLAP data warehouse in general, reporting through Discoverer or BI Beans? Any opinions?
    thanks
    Mark

  • Lost link between iPhoto library and iPhoto.app

    While learning how to use Photoshop Elements 4.0 and Bridge, I made the choice to "browse" in Bridge. When I next started iPhoto 6.06, my link to the Library was lost. I have worked with AppleCare support, done every exercise short of creating a new library and losing my organization. With 20,000 + photos I would like to avoid that exercise. I do have backups but am trying to figure out if I can solve this any other way. All my files are still in iPhoto Library, and I can see the organization of my albums in Bridge. With some exercises, I get the message: "Unreadable files: 1. The following file could not be imported: '/Users/john/Pictures/iPhoto Library/Library.iPhoto.'"
    If I delete Adobe Photoshop Elements and Bridge from the hard drive, will this help? I promise I did not do anything within iPhoto Library in Finder!
    Thanks so much!
    iMac   Mac OS X (10.4.9)   iPhoto 6.06
    iMac   Mac OS X (10.4.9)   iPhoto 6.06
    iMac   Mac OS X (10.4.9)   iPhoto 6.06

    cdkayak
    Welcome to the Apple Discussions.
    There's absolutely no harm in using PSE with iPhoto, it's Bridge that's a killer. So that's what you chuck from your machine. Set up PSE as an external editor in the iPhoto Preferences. That way you can double click a pic in iPhoto and it will open automatically in PSE, save it PSE and have it come back into iPhoto seamlessly.
    What's likely happened here is that you have (or Bridge has) made changes in the iPhoto Library Folder which has broken the link between iPhoto and the library files.
    Some things to try:
    Hold down the option (or alt) key and launch iPhoto. Choose Locate, and point iPhoto at the iPhoto Library Folder.
    What Back Ups do you have? If there's an up-to-date one, then try copying the library6.iphoto file from it to the iPhoto Library Folder allowing it to overwrite the confused one.
    That said, if these don't work, your options will only be to create and populate a new library: To create and populate a new library:
    Note this will give you a working library with the same film rolls and pictures as before, however, you will lose your albums, keywords, books, calendars etc.
    Move the iPhoto Library Folder to the desktop
    Launch iPhoto. It will ask if you wish to create a new Library. Say Yes.
    Go into the iPhoto Library Folder on your desktop and find the Originals folder. From the Originals folder drag the individual rolls to the iPhoto Window and it will recreate them in the new library.
    When you're sure all is well you can delete the iPhoto Library Folder on your desktop.
    In the future, in addition to your usual back up routine, you might like to make a copy of the library6.iPhoto file whenever you have made changes to the library as protection against database corruption.
    Finally, the message
    "Unreadable files: 1. The following file could not be imported: '/Users/john/Pictures/iPhoto Library/Library.iPhoto.'"
    is because iPhoto will not import a picture that's in the active iPhoto Library Folder - a sensible precaution against duplication.
    Regards
    TD

  • Desperate for help: My iPhoto library is "unreadable"

    HELP!
    Earlier I tried to open my iPhoto library and it prompted me with a weird message that I've never seen in all of my years using the software. I forget the exact words of the alert because this occurred like two hours ago, but it was something along the lines of needing to upgrade my software in order to view my current library. Although I have an up-to-date version of iPhoto '08, I continued.
    Now, my iPhoto library quite literally went back in time; I don't have any of the photos I've imported since 2007, and the ones that are there are unnamed and unorganized.
    I was able to locate the images on my hard drive, but when I try to import them to the library, I get an error message: "The following files are unreadable because they are an unrecognizable format," or "The following files are unreadable or are already located in the library."
    I'm desperate to get those photographs back into my library, and I have tried everything. I downloaded a software called iPhoto Library Manager, and I've tried to rebuild iPhoto directly, but I kept getting error messages. Does anybody have any advice?

    Welcome to the Apple Discussions.
    iPhoto will not import pics from the active iPhoto Library - a sensible protection against duplication.
    Your database file is damaged, and as iPhoto Library Manager cannot rebuild it, you’ll need to either
    1. Restore from your back up
    or
    2. Create a new Library and start over:
    To create and populate a new *iPhoto 08* library:
    Note this will give you a working library with the same Events and pictures as before, however, you will lose your albums, keywords, modified versions, books, calendars etc.
    In the iPhoto Preferences -> Events Uncheck the box at 'Imported Items from the Finder'
    Move the iPhoto Library to the desktop
    Launch iPhoto. It will ask if you wish to create a new Library. Say Yes.
    Go into the iPhoto Library (Right Click -> Show Package Contents) on your desktop and find the Originals folder. From the Originals folder drag the individual Event Folders to the iPhoto Window and it will recreate them in the new library.
    When you're sure all is well you can delete the iPhoto Library on your desktop.
    In the future, in addition to your usual back up routine, you might like to make a copy of the library6.iPhoto file whenever you have made changes to the library as protection against database corruption.
    Regards
    TD

  • Can't Add to New iPhoto 5

    Good morning.
    I just reinstalled iPhoto 5.0 and it didn't seem to import my photos from the library. There is something in the iPhoto window (grey boxes) but no photos. I've tried to 'Add to Library' from my existing iPhoto folder but I get a message saying:
    The following files could not be imported (the may be an unrecognized file type or the files may not contain valid data.)
    The files are all jpegs and I am able to open them with Preview so there is valid data in them.
    Any ideas on what might be going on?
    Cheers,
    BurntMonkey

    BurntMonkey
    iPhoto will not import pics from the iPhoto Library Folder - a sensible precaution against duplication.
    Check out
    http://docs.info.apple.com/article.html?artnum=107947
    for help recovering from the situation.
    Regards
    TD

Maybe you are looking for