Increase the length of the column - restriction key foreign vs MS SQL

Hello

I need to increase the length of the column (nvarchar) in some tables. Between these tables are foreign keys.

When I try to do it on MS SQL databases using the command as "ALTER TABLE TABLE_NAME ALTER COLUMN column NAME NVARCHAR (50) NULL" then I get the error like below:

Column ' dbo. TABLEA. NAME ' is not the same length or scale as the referencing column or the 'FKNAME' object depends on the column 'name'.

Therefore resume, on MS SQL I drop all constraints, alter table and re-create constraints.

When I do this same thing on the oracle database (oracle database a same pattern as MS SQL database, same fk, same tables, columns, etc.) using the command as "ALTER TABLE table_name MODIFY COLUMN NVARCHAR2 (40);  " then length is change without any erros and I wounder t - it a correct situation on oracle? -all the constraints are enabled. Oracle checks the length of data to foreign key columns?

As I understand the error (ORA-02267: column type incompatible with the type of the referenced column) is the show that if the data type name is not equal between data tables not type length (?)

To reproduce:

1 create tables

CREATE TABLE "TABLEA".

(ACTIVATE THE 'NAME' NVARCHAR2 (20) NOT NULL,)

NUMBER OF "TEXTID",.

'PK_TABLEA' CONSTRAINT PRIMARY KEY ("NAME")

);

CREATE TABLE 'TABLEB.

(SELECT 'ID' NUMBER NOT NULL,)

NVARCHAR2 (10) "NAME."

NUMBER OF "WWW."

"TABLEB' ('ID') PRIMARY KEY CONSTRAINT

);

2. create the fk

ALTER TABLE TABLEB ADD CONSTRAINT FK_TABLEB FOREIGN KEY ('NAME') REFERENCES 'TABLEA' ('NAME');

On MS SQL, you get an error message on the same length of column ;) no

Thank you

Best regards

Mateusz

Whatever it is, the answer seems to be here: https://docs.oracle.com/cd/E17952_01/refman-5.5-en/create-table-foreign-keys.html

"Corresponding columns in the foreign key and the referenced key must have similar data types. The size and the sign of the integer types must be the same. The length of the string types are not necessarily the same. For the non-binary (character) string, the character set and collation columns must be the same. "

Tags: Database

Similar Questions

  • Cannot change the type of data in the columns referenced by foreign keys

    Hello:

    I'm using Version 3.1.0.691 and change the types of data in many columns of data derived from the field types. If a column is referenced by a foreign key, however, the data type radio buttons are grayed out. I suppose that if I deleted the foreign key, that I would be able to change the data type of the column to a field, but that would be tedious. Is there another way to go about this?

    Any help would be greatly appreciated.

    Thank you

    Doc

    Hi Doc,

    If a column is referenced by a foreign key, however, the data type radio buttons are grayed out.

    It is not good - if you have the PK column, and it is called by another FK column you can change the data type of column PK and FK column data type will follow the change. You cannot manually change the data type of column FK. Good column PK itself could relate to another column, and in this case you cannot change the data type of column PK.
    In your case - you need to find the first PK/Uk column that is not the column FK itself and change its data type. FK columns in the chain will follow.

    Philippe

  • Increase the column width in an IR

    Hello

    I tried to increase the size of a column in an IR

    I found a way to change the title of
    <div style=""> Name </div>
    The problem is that I got the code div too, when I do a CSV export.

    Y at - it something to avoid this?

    Thank you

    Uji.

    Hello

    Check out Apex generated div id of the tag. Usually, it is apexir_ and the alias column.
    You can inspect HTML easily with Firefox and Firebug.

    Add in the HTML page header

    
    

    Where apexir_ENAME is the id of the div tag Apex has generated for report heading div

    BR, Jari

    Published by: jarola on June 10, 2010 11:49

    typos corrected

  • How can I replace the value of the column with a particular value in SQL

    Hi all

    Is someone can you please tell me how can I format my output with the replacement of a column value with a specific value that really depends on the current value of the column

    I am executing the following SQL statement

    Select state, count (id) from < table_name > where composite_dn = < composite_dn_name > Group by State;
    My current performance is:

    State Instance number
    1 3
    3 28

    I want to replace the value in the State column as follows

    No.OfInstances State
    3 filled
    28 faulted

    I want '1' to be reppaced of 'Done' and '3' is replaced by 'Faulted. '

    Is is possible with SQL or PL/SQL, if it is then how I can achieve this required. Help, please!

    Thanks in advance!

    Published by: Roshni Shankar on October 27, 2012 12:38 AM

    Hi Claude,.

    I guess this CASE clause can be simulated by a DECODE and also it is very easy to use.
    See - http://www.techonthenet.com/oracle/functions/decode.php

    select decode(t1.state,t2.state_id,t2.state_name), t1.count_id
    from  t2, (select state,count(id) count_id
     from 
     where composite_dn= 
    group by state) t1
    where t1.state = t2.state_id;
    

    HTH
    Vanessa B.

    Published by: Vanessa B on October 27, 2012 14:02
    -link added

    Published by: Vanessa B on October 27, 2012 14:19
    -added code sample

  • How to increase the column header

    Hello, can I know Table or in Labview 2012 multicolumn Listbox is available to change the format of the header of column as picture below?

    I don't think you can merge cells (like Excel) with a MCL LabVIEW

  • Need help to build the query/pl-sql block to get the query result and the name of column from DB table in the form of key-value pairs.

    Hi Experts,

    I have a DB table has columns of more than 50.

    I question this table, it should only return one line at any time. as sqldeveloper below image.

    here, I need to build block pl/sql-query, Discover the column in the table as a key and query result as values.

    Eg:     Key                         -  Value

    TASK_EVENT_ID - 1765

    EVENT_TYPE - ASR_UPDATE

    ... etc until all of the columns in my table.

    Experts please comment on that point, appreciate your help on this.

    Thank you

    -Vincent.

    Here is an approach using DBMS_SQL to iterate over the columns of key / value to assign... (Little code snipped for brevity)

    create or replace procedure (task_expired)

    v_store_id in full,

    v_task_action_id in full,

    v_job_id in full

    )

    as

    -[SNIP code...]

    v_sql VARCHAR2 (4000): = ' select * from my_table where PK = 123';  -Your SQL here!

    v_v_val VARCHAR2 (4000);

    v_n_val NUMBER;

    v_d_val DATE;

    v_ret NUMBER;

    c NUMBER;

    d NUMBER;

    col_cnt INTEGER.

    f BOOLEAN;

    rec_tab DBMS_SQL. DESC_TAB;

    col_num NUMBER;

    vAsString VARCHAR2 (4000);

    BEGIN

    -[SNIP code...]

    Message_properties. CORRELATION: = "EDF_EVENT";

    MSG: = SYS. AQ$ _JMS_BYTES_MESSAGE. Construct();

    Msg.set_string_property ('queueName', ' shipping/csi_cth');

    Msg.set_string_property ('MODE', 'CR8');

    c: = DBMS_SQL. OPEN_CURSOR;

    DBMS_SQL. PARSE (c, v_sql, DBMS_SQL. NATIVE);

    d: = DBMS_SQL. Execute (c);

    DBMS_SQL. DESCRIBE_COLUMNS (c, col_cnt, rec_tab);

    1.col_cnt J

    LOOP

    CASE rec_tab (j) .col_type

    WHEN 2 THEN

    DBMS_SQL. DEFINE_COLUMN (c, j, v_n_val);      -Number

    WHEN 12 CAN

    DBMS_SQL. DEFINE_COLUMN (c, j, v_d_val);      -Date

    ON THE OTHER

    DBMS_SQL. DEFINE_COLUMN (c, j, v_v_val, 2000);   -Else treat as varchar2

    END CASE;

    END LOOP;

    LOOP

    v_ret: = DBMS_SQL. FETCH_ROWS (c);

    WHEN OUTPUT v_ret = 0;

    1.col_cnt J

    LOOP

    -Fetch each column to the correct data type based on coltype

    CASE rec_tab (j) .col_type

    WHEN 2 THEN

    DBMS_SQL. COLUMN_VALUE (c, j, v_n_val);

    vAsString: = to_char (v_n_val);

    WHEN 12 CAN

    DBMS_SQL. COLUMN_VALUE (c, j, v_d_val);

    vAsString: = to_char (v_d_val, ' DD/MM/YYYY HH24:MI:SS');

    ON THE OTHER

    DBMS_SQL. COLUMN_VALUE (c, j, v_v_val);

    vAsString: = v_v_val;

    END CASE;

    Msg.set_string_property (rec_tab (j) .col_name, vAsString);

    END LOOP;

    END LOOP;

    DBMS_SQL. CLOSE_CURSOR (c);

    DBMS_AQ. ENQUEUE (queue_name-online 'cbus.aqjms_common',

    Enqueue_options => Enqueue_options,

    Message_properties => Message_properties,

    Payload-online msg,

    Msgid => Message_handle);

    dbms_output.put_line ('00 Msgid =' |) Message_handle);

    dbms_output.put_line('===Done=');

    -[SNIP code...]

    END;

    /

  • Find the column for a constraint name

    Hi guru,.

    I know the name of the constraint, now I need the column name and the name of the table of the constraint?

    Thank you

    Ask the USER_CONS_COLUMNS then you'll find the column name and table name

    SQL > Select * from USER_CONS_COLUMNS where Constraint_Name = "";

  • Increase the length of the name of access policy

    Hi all

    I need to use a longer name for the access (i.e. longer than 30 characters) policy.

    Is it ok, if I change the length of the POL_NAME of the POL table column?
    How can I increase the length of the name field in the client side access policy (i.e. in the administrative web page IOM and Console user)?


    Kind regards
    Chaturanga

    Hi Chaturanga, like I said that I wasn't able to test that. Now I tested, it doesn't work. For groups, we in the same way that's why I suggested you like that.

    You need to change xlWebApp/tiles/CreateAccessPolicyTiles.jsp instead of CreateAccessPolicyDetailTiles.jsp

    I think that user774847 wrongly written JSP name.

  • I wanted to know how I can increase the font in the column of the mailbox to the left

    I wanted to know how I can increase the font in the column of the mailbox to the left

    Increase in the size of message font list option is available only if you select the classic layout.

    When you disable the provision of the 'classic' use and return to the new layout, you need to move

    the pointer of the mouse to the line splitter between the message and the list of messages and drag to the left

    to decrease the width of the column of the message list.

    Mail > Preferences > display

  • My organization is planning on increasing the length of password of 6 to 8 characters. Will what effect have on users?

    Users are invited to increase the length of their password the next time that they are required to change their password or is change immediately for all users at 6 characters or less?

    Hello

    Thank you for keeping us posted.

    I apologize for the delay in responding.

    I would have you post your query in the TechNet forums.

    Check out the link-

    http://social.technet.Microsoft.com/forums/en-us/category/WindowsServer

    Back to us for any issues related to Windows in the future. We will be happy to help you.

  • I racer Ferrari 1000, right key is damaged so I can't increase the brightness of my screen.

    I racer Ferrari 1000, right key is damaged so I can't increase the brightness of my screen.

    I'm glad that you guessed it work.

  • How to change the width of key column when you view files in the Explorer window?

    Can someone help me with this one major annoyance I have with Vista?

    I opened an Explorer window and I want to resize the first column, so I can see the full file name.  (First I accidentally spend whole column name because I can't seem to find my mouse to keep the resizing grabber.)   Now that I have the desired column width, is it possible to make the column width by default for all future Explorer Windows I open?   I've grown very tired of having to resize this column whenever I open an Explorer window.

    Thank you!

    CTRL-click this link to read a thread of responses on increasing you the Vista folder settings memory.

    My user folder moves around:

    Here's another on a good tutorial

    View of folders:

    Messages rating helps other users

    Mark L. Ferguson MS - MVP

  • Disable the column key functional for an individual of forms

    Hi all

    I have a block of multiple registration details in my form with fields (type, point, wt, vehicle number etc.). Keys are already scheduled for functional use as f3 to copy.

    In my form, I want to use the copy function to get to the fields as type, point, wt, but not for the vehicle number column. IE type, point, maybe same wt columns but number of vehicle may not be same (according to customer requirement). They will not accidentally copying the same number of vehicle.

    For this I need to disable the copy (F3) function for this vehicle only number column.

    Is there a workaround for this...

    My version of the form is 10g

    Thanks in advance

    Concerning

    JaKes

    the KEY-F3-trigger has nothing to do with the F3 function key. In client-server F3 is associated with the DUPLICATE_ITEM function, so you should use the KEY-DUPITM-trigger.

    Also, if you implement a release BUTTON, it replaces the functionality by default, so you must manage the service for yourself.

    As for the OP functionality should just be deleted at one, the simplest solution is to create KEY-DUPITM-relaxation so precise and simple insert a value that is NULL. inside.

  • How to join two tables to retrieve the data from the columns in table two. Tables have primary and foreign key relationships

    Hello

    I want to join the two tables to retrieve the data from the columns of the two table passing parameters to the join query. Tables have primary and foreign key relationships

    Details of the table

    Alert-1 - AlertCode (FK), AlerID (PK)

    2 AlertCode-AlertDefinition-(PK)

    Help, please


    ----------

    Hi Vincent,.

    I think that you have not worked on adf 12.1.3.  In adf 12.1.3 you don't have to explicitly create the association. When you create the EO to your table, Association xxxxFkAssoc, will be created by ADF12.1.3 for you automatically. Please try this and do not answer anything... You can also follow the links below. I solved the problem by using the following link

    Oracle ADF Guide step by step - Oracle ADF tutorial: creating a relationship of the master / detail using Oracle ADF

    ---

  • When I have a constarint of deferable in the Oracle database, while creating the ADF BC, all the columns in this table is marked as primary key. any help on how to fix this?

    DROP TABLE TWO.

    DROP TABLE ONE;

    CREATE TABLE 'A

    (

    ACTIVATE THE 'ID' NUMBER NOT NULL,

    ACTIVATE THE "SERIAL" VARCHAR2 (10 BYTE) NOT NULL,

    ACTIVATE THE "FIRST NAME" VARCHAR2 (30 BYTE) NOT NULL,

    ENABLE 'PK_ONE' CONSTRAINT PRIMARY KEY ('ID', "SERIAL")

    )

    TABLESPACE 'USERS ';

    CREATE TABLE "TWO"

    (

    ACTIVATE THE 'ID' NUMBER NOT NULL,

    ACTIVATE THE "SERIAL" VARCHAR2 (5 BYTE) NOT NULL,

    ACTIVATE THE "DEGREE_CODE" VARCHAR2 (10 BYTE) NOT NULL,

    'TEST_NAME' VARCHAR2 (20 BYTE),

    ACTIVATE THE KEY PRIMARY CONSTRAINT 'PK_TWO' ('ID', 'SERIAL'),

    "FK_TWO' FOREIGN KEY ('ID', 'DEGREE_CODE') CONSTRAINT REFERS TO 'ONE' ('ID', 'SERIAL') MAYBE DEFERRED ENABLE

    )

    TABLESPACE 'USERS ';

    If we use the above sql scripts to create the tables and create the ADF BC using the above 2 tables, all 4 columns in table 2 are reported as the primary key.

    User, tell us your version of Jdev, please!

    You should file an SR with support.oracle.com for this.

    As a work around you can change the area of occurrence, and remove the check mark key pirmary on the unwanted columns. After that, it should work.

    Timo

Maybe you are looking for