Solved

Oracle Add a Column. Set Default Value to False

Posted on 2014-09-08
6
570 Views
Last Modified: 2014-09-08
I have a table named TableA. I need to add a column named Delete_Me.

The new column needs a default value of false.

Which is a better datatype choice, VarChar2(1) or Number defaulted to 0 ?

What is the syntax for creating the new column?

Thanks,
0
Comment
Question by:Dovberman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 6

Accepted Solution

by:
Mandeep Singh earned 150 total points
ID: 40311336
alter table table_name
add (column1_name column1_datatype column1_constraint);

Open in new window


ALTER TABLE user ADD Delete_Me VARCHAR2(1) DEFAULT 'N' NOT NULL
0
 
LVL 48

Assisted Solution

by:PortletPaul
PortletPaul earned 150 total points
ID: 40311337
ALTER TABLE TableA
  ADD ( Delete_Me int default 0 not null ) ;

I would use an integer.
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 200 total points
ID: 40311361
well, you have this:
http://docs.oracle.com/cd/E17952_01/refman-5.1-en/bit-type.html
BIT(1) would be the correct choice...


TINYINT and CHAR(1) (and not VARCHAR...) will use up 1 byte
see here:
http://docs.oracle.com/cd/E17952_01/refman-5.5-en/storage-requirements.html
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Dovberman
ID: 40311367
is BIT(1) available in Oracle 10g?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40311375
I think it's only available from Oracle 11.2, but not sure...
0
 

Author Closing Comment

by:Dovberman
ID: 40311395
Thanks
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question