插入空值时出现问题

时间:2014-04-06 17:22:49

标签: sql

所以我一直在寻找答案,我知道这将是一些基本而愚蠢的东西,我忽略了但是对于我的生活,我看不到它。

在INSERT INTO“”值点,我无法插入空值..我需要空格为空。 :/

Drop table Patient;
Drop table Kennel;
Drop table Prescription;
Create Table Patient 
(
Patient_ID               NUMBER,
Name                     VARCHAR2(15),
DOB                      date,
PRIMARY KEY(Patient_ID)
);
Create Table Kennel
(
Kennel_No                VARCHAR2(2),
Kennel_Section           VARCHAR2(1),
Admission_Date           date,
Patient_ID               NUMBER, 
PRIMARY KEY(Kennel_No),
foreign key (Patient_ID) references Patient
);
Create Table Prescription 
(
Prescription_Date        date,
Drug_Code                VARCHAR2 (5),
Drug_Name                VARCHAR2 (55),
Dosage                   VARCHAR2 (25),
Num_Days_Dosage  NUMBER ,
Kennel_No  VARCHAR(255),
foreign key (Kennel_No) references Kennel 
);
INSERT INTO Patient VALUES   (1234,'Wiggles','12 Dec 1996');
INSERT INTO Patient VALUES   ('','','');
INSERT INTO Patient VALUES   (4587, 'Woofy', '15 Nov 1999');
INSERT INTO Patient VALUES   ('', '','');
INSERT INTO Patient VALUES   ('', '','');
INSERT INTO Patient VALUES   (4692,'Hiccup','3 Apr 1998');
INSERT INTO Patient VALUES   ('', '','');
INSERT INTO Patient VALUES   ('', '','');
INSERT INTO Patient VALUES   (5432, 'Sandy', '2 Jun 2002 ');
INSERT INTO Patient VALUES   ('', '', '');
INSERT INTO Patient VALUES   ('', '', '');
INSERT INTO Patient VALUES   (2591, 'Snoopy', '28 Aug 2001');
INSERT INTO Patient VALUES   ('', '', '');
INSERT INTO Patient VALUES   (4563, 'Dopey', '1 Apr 2004');
INSERT INTO Kennel  VALUES   (23,'A', '20 Oct 2005');
INSERT INTO Kennel  VALUES   ('', '', ''); 
INSERT INTO Kennel  VALUES   (28, 'B', '10 Nov 2005');
INSERT INTO Kennel  VALUES   ('', '', '');
INSERT INTO Kennel  VALUES   ('', '', '');
INSERT INTO Kennel  VALUES   (25, 'A', '21 Nov 2005');
INSERT INTO Kennel  VALUES   ('', '', '');
INSERT INTO Kennel  VALUES   ('', '', '');
INSERT INTO Kennel  VALUES   (35,'C', '30 Nov 2005');
INSERT INTO Kennel  VALUES   ('', '', '');
INSERT INTO Kennel  VALUES   ('', '', '');
INSERT INTO Kennel  VALUES   (34, 'C', '04 Dec 2005');
INSERT INTO Kennel  VALUES   ('', '', '');
INSERT INTO Kennel  VALUES   (30, 'B', '06 Dec 2005');
INSERT INTO Prescription  VALUES  ('20 Oct 2005', 'CO156', 'Cortisone', '2 pills, 3 times a day', 14, 23);  
INSERT INTO Prescription  VALUES  ('23 Oct 2005', 'AP566','Aspirin', '1 pills, 3 times a day', 10, 23);
INSERT INTO Prescription  VALUES  ('13 Nov 2005','PE312', 'Penicillin', '1 pill, 3 times a day', 5, 28);
INSERT INTO Prescription  VALUES  ('14 Nov 2005','AP566', 'Aspirin', '2 pills, 2 times a day', 14, 28); 
INSERT INTO Prescription  VALUES  ('15 Nov 2005','CO156', 'Cortisone', '2 pills, 3 times a day', 10, 28); 
INSERT INTO Prescription  VALUES  ('22 Nov 2005','PE312', 'Penicillin', '1 pill, 3 times a day', 2, 25);
INSERT INTO Prescription  VALUES  ('23 Nov 2005', 'AP566','Aspirin', '2 pills, 2 times a day', 10, 25);
INSERT INTO Prescription  VALUES  ('24 Nov 2005', 'BE159', 'Benzocaine', '2 pills, 3 times a day', 7, 25);
INSERT INTO Prescription  VALUES  ('30 Nov 2005', 'CO156', 'Cortisone', '1 pill, 3 times a day', 7, 35);  
INSERT INTO Prescription  VALUES  ('02 Dec 2005', 'AP566', 'Aspirin', '2 pills, 2 times a day', 12, 35);
INSERT INTO Prescription  VALUES  ('03 Dec 2005', 'BE159', 'Benzocaine', '2 pills, 3 times a day', 2, 35);
INSERT INTO Prescription  VALUES  ('04 Nov 2005', 'CO156', 'Cortisone', '1 pill, 3 times a day',10, 34);
INSERT INTO Prescription  VALUES  ('05 Dec 2005', 'AP566', 'Aspirin', '2 pills, 2 times a day', 8, 34);
INSERT INTO Prescription  VALUES  ('06 Nov 2005', 'PE312', 'Penicillin', '3 pills, 3 times a day',7,30);

1 个答案:

答案 0 :(得分:0)

您的列设置为允许空值,和/或您没有默认值。 检查桌子上的设置。