Solved

Oracle Add a Column. Set Default Value to False

Posted on 2014-09-08
6
576 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Creation date for a PDB 5 87
Create file system directory from Oracle 10g 4 46
Read XML values 8 70
PL/SQL: ORA-00979: not a GROUP BY expression 3 83
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to recover a database from a user managed backup

752 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