الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

للعباقرة فقط

مغلق
بدأه islame في 8 ديسمبر 2003 · 8 رد · 816 مشاهدة · في قواعد بيانات Oracle
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

Hi:

I had a question in oracle 9i developer.

First if I have an EMP table that has

(for example)

Deptno number(2 (

And the column contain a data and null value

How can I modify the column definition to become not null.

and still the data in it(without delete the data )

#2

Alter Table EMP Modify Deptno number(2) Default 0 Not Null;

#3

Hi acidface

if there is a Foriegn key constraint on DeptNo that references to master table

and there is no DeptNo = 0

then your statment will fail because there is an integrity voilation

Abo Qosai

#4

Hi:

the emp table contain data and this statment will fail

#5

yes i know Abo_Qosai it will fail but i mean by this statement that u have to assign default value for the null fields

u can change this zero value by any department number that exists in ur dept table

or u have to disable the forign key .

#6

الاخت اسلام لماذل لم تضعى سوالك بالعربى لتعم الفائدة ؟؟!!

بالنسبة لسوالك منتهى السهولة انشى جدول جديد باى اسم على ان تكون به نفس حقول الجدول الممتلى بالبيانات وعرفى الحقل بانه ليس فارغأ فى جملة انشاء الجدول ومن ثم قم بانشاء اجراء يقوم بنقل البيانات من الجدول الاول الى الجدول الثانى ومن ثم بعد التاكد من نقل كل البيانات يمكنك حذف الجدول الاول ومن ثم تسميت الجدول الثانى باسم الجدول الاول ون وجدت علاقات اعيدى تكوينها والسلام.

سبحان الله و الحمد لله لا اله الا الله و الله اكبر

#7

Hi:

Thank you for all solution but I need to say I want to modify

The column (Deptno) itself without disables constraints, or build anther

Table and create a new relation.

You can make it in oracle9i but this is advanced topic in SQL

I need to know it

Best regards

Islame

#9

السلام عليكم

قد تجد ضالتك في هذا الكود

Update emp

set deptno=nvl(deptno,0);

او

Update emp

set deptno=0

where deptno is null;

وبعد تطبيق اي من هذين الكود لايصبح عندك اي قيم

تحتوي علي

null

(يمكنك استبدال الصفر باي رقم ترغب فيه )

ولذا يمكنك بعد ذلك ان تعدل الجدول لتجعل ذلك العمود لابد ان يحتوي علي قيم

اي

not null

السلام عليكم

هذا الموضوع مغلق.

مواضيع مشابهة