473,385 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

what's the problem with query

CREATE TABLE "calc_modes" (
"template" VARCHAR2(20) NOT NULL,
"code" VARCHAR2(20) NOT NULL,
"name" VARCHAR2(40) NULL,
"type" NUMBER(4) NULL DEFAULT (0)
)

what is the proble with this query
Mar 15 '07 #1
3 1934
mivey4
37
CREATE TABLE "calc_modes" (
"template" VARCHAR2(20) NOT NULL,
"code" VARCHAR2(20) NOT NULL,
"name" VARCHAR2(40) NULL,
"type" NUMBER(4) NULL DEFAULT (0)
)

what is the proble with this query
Remove the double quotes and if the column TYPE is to be assigned a default value, then how can it be null?

It's either allowed NULL values or assigned a default value but not both.

CREATE TABLE calc_modes (
template VARCHAR2(20) NOT NULL,
code VARCHAR2(20) NOT NULL,
name VARCHAR2(40) NULL,
type NUMBER(4) DEFAULT 0
);

Good Luck.
Mar 15 '07 #2
Dave44
153 100+
Remove the double quotes and if the column TYPE is to be assigned a default value, then how can it be null?

It's either allowed NULL values or assigned a default value but not both.

CREATE TABLE calc_modes (
template VARCHAR2(20) NOT NULL,
code VARCHAR2(20) NOT NULL,
name VARCHAR2(40) NULL,
type NUMBER(4) DEFAULT 0
);

Good Luck.
mivey4,

giving a table column a default value has nothing to do with whether or not it can be null. And there may be perfectly valid reasons for giving a nullable field a default value and visa versa.
Expand|Select|Wrap|Line Numbers
  1. [138]dave@ORADB> create table a (
  2.   2  col1  number  default 1 not null,
  3.   3  col2  number  default 2 null );
  4.  
  5. Table created.
  6.  

what you cannot do is this:
Expand|Select|Wrap|Line Numbers
  1. [138]dave@ORADB> insert into a values (1,null);
  2.  
  3. 1 row created.
  4.  
  5. [138]dave@ORADB> alter table a modify col2 not null;
  6. alter table a modify col2 not null
  7. *
  8. ERROR at line 1:
  9. ORA-02296: cannot enable (DAVE.) - null values found
  10.  
Mar 19 '07 #3
mivey4
37
mivey4,

giving a table column a default value has nothing to do with whether or not it can be null. And there may be perfectly valid reasons for giving a nullable field a default value and visa versa.
Expand|Select|Wrap|Line Numbers
  1. [138]dave@ORADB> create table a (
  2.   2  col1  number  default 1 not null,
  3.   3  col2  number  default 2 null );
  4.  
  5. Table created.
  6.  

what you cannot do is this:
Expand|Select|Wrap|Line Numbers
  1. [138]dave@ORADB> insert into a values (1,null);
  2.  
  3. 1 row created.
  4.  
  5. [138]dave@ORADB> alter table a modify col2 not null;
  6. alter table a modify col2 not null
  7. *
  8. ERROR at line 1:
  9. ORA-02296: cannot enable (DAVE.) - null values found
  10.  
Sorry about that,

You are absolutely correct, Dave. I didn't devote a lot of thought on that until after I'd posted the response. Thanks for the correction.

mivey4
Mar 19 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: lkrubner | last post by:
I have a webserver through Rackspace. I create a domain. I create an FTP user. I upload some files. I create a database called testOfSetupScript and then I create a database user named setup. I...
8
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
1
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
4
by: frank | last post by:
I posted a question before (to too many groups) and this time I am sending to this group only. I have a quick script as seen below, the file_list table has a unique field called file_name. The...
3
by: Andy_Khosravi | last post by:
I have been trying to build a user friendly search engine for a small database I have created. I'm having some particular problems with one of my date fields. Here's the setup: I'm using...
5
by: JIM.H. | last post by:
Hello, I am trying to send Where clause as a parameter. Here is the detail: Select statment: // sqlSelectCommand1 // this.sqlSelectCommand1.CommandText = "SELECT * " + " FROM myTable " + "...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
9
by: Brian Hampson | last post by:
I am trying to determine all the groups which the current user has permissions to add a member. Here's my code: foreach (System.DirectoryServices.SearchResult ADSearchres in...
6
by: CTG | last post by:
"update set UPDATE-FLAG=false, UPDATE-DT= '10/09/2007 4:09:59 PM' WHERE ICCID='I1' " UPDATE_FLAG is a YES/NO ICCID is TEXT I have tried YES, NO as well but still fails,
9
by: QCLee | last post by:
Sir can you help me to transfer my Access Query to MS excel? i have a command button on the form to export the parameter query named "HVACWindwardQuery" to excel spreadsheet and i got the codes...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.