Solved

Oracle Add a Column. Set Default Value to False

Posted on 2014-09-08
6
547 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
6 Comments
 
LVL 6

Accepted Solution

by:
Mandeep Singh earned 150 total points
Comment Utility
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
Comment Utility
ALTER TABLE TableA
  ADD ( Delete_Me int default 0 not null ) ;

I would use an integer.
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 200 total points
Comment Utility
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:Dovberman
Comment Utility
is BIT(1) available in Oracle 10g?
0
 
LVL 142

Expert Comment

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

Author Closing Comment

by:Dovberman
Comment Utility
Thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to recover a database from a user managed backup

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now