Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Oracle Add a Column. Set Default Value to False

Posted on 2014-09-08
6
Medium Priority
?
611 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 600 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 49

Assisted Solution

by:PortletPaul
PortletPaul earned 600 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 800 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
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.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Suggested Courses

885 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