Solved

Oracle Add a Column. Set Default Value to False

Posted on 2014-09-08
6
555 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
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 142

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
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
ID: 40311367
is BIT(1) available in Oracle 10g?
0
 
LVL 142

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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PL/SQL - Leading zeros 7 57
Dataware house query tuning 9 64
Need a replacement data type in Oracle 6 65
PL SQL Search Across Columns 4 18
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…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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

911 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

20 Experts available now in Live!

Get 1:1 Help Now