Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


BIT datatype and Oracle


BIT datatype and Oracle

Author
Message
SREERAJ. R
SREERAJ. R
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 53
Hi,

As per the business requirement, any SQL script that I make should follow ANSI standard, so that it should successfully execute in both SQL Server 2005 and Oracle.

Recently I noticed that for flag columns the datatype VARCHAR(5) is used which will store either 'True' or 'False' inorder to make it executable in Oracle also!. Now I think to use a BIT data type, but it seems Oracle doesn't have such a type. Can I use SMALLINT so that 1 or 0 can be stored? Is this type supported in Oracle?
Jo Pattyn
Jo Pattyn
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1589 Visits: 9725
Smallint can be used to store 0 or 1, but isn't supported in Oracle (has number datatype).
ANSI<->TSQL
ANSI<->Oracle
PaulB-TheOneAndOnly
PaulB-TheOneAndOnly
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3093 Visits: 4639
SREERAJ. R (8/8/2012)
Hi,

As per the business requirement, any SQL script that I make should follow ANSI standard, so that it should successfully execute in both SQL Server 2005 and Oracle.

Recently I noticed that for flag columns the datatype VARCHAR(5) is used which will store either 'True' or 'False' inorder to make it executable in Oracle also!. Now I think to use a BIT data type, but it seems Oracle doesn't have such a type. Can I use SMALLINT so that 1 or 0 can be stored? Is this type supported in Oracle?


I would settle for varchar2(1) and store either "T" or "F" so to make it closer to what you have today.

_____________________________________
Pablo (Paul) Berzukov

Author of Understanding Database Administration available at Amazon and other bookstores.

Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
SREERAJ. R
SREERAJ. R
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 53
I am afraid Varchar2 will not work in SQL Server...

Is INTEGER supported in Oracle?

Sorry, that I don't have an Oracle installation to test.
HowardW
HowardW
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1211 Visits: 9892
Yes INTEGER is supported. The smallest mutually available data type for this would be CHAR(1) (which is 1 byte in each) and you can use Y/N or T/F or whatever...
EdVassie
EdVassie
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3144 Visits: 3816
Does your business know how much cost and time they are adding by forcing people to write code that can run on multiple types of DBMS?

This is like saying you need to buy vehicles that can run on either diesel or gasoline and preferably also jet fuel, just so you can use the nearest nozzle at the filling station. It can be done, but the cost and time is horrendous and you get NO business advantage.

Original author: SQL Server FineBuild 1-click install and best practice configuration of SQL Server 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005. 1 Dec 2016: now over 39,000 downloads.
Disclaimer: All information provided is a personal opinion that may not match reality.
Quote: "When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist." - Archbishop Hélder Câmara
HowardW
HowardW
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1211 Visits: 9892
EdVassie (8/9/2012)
Does your business know how much cost and time they are adding by forcing people to write code that can run on multiple types of DBMS?

This is like saying you need to buy vehicles that can run on either diesel or gasoline and preferably also jet fuel, just so you can use the nearest nozzle at the filling station. It can be done, but the cost and time is horrendous and you get NO business advantage.


Hmm, that does depend. I'm not an advocate of needlessly jumping through hoops to make code portable if you're only actually developing against a single platform, but say you work for a software company that wants to ship its product on various database platforms?

Many companies have a strong preference for a particular database platform for their own internal support costs, so it can rule you out of the selection process if your product doesn't support Oracle/SQL Server and a competitor's does.
EdVassie
EdVassie
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3144 Visits: 3816
True - if you are writing a multi-platform product then you are limited in what you can do, and you have to accept the costs of doing this.

The OP did not sound like this was a multi-platform product, just a IT department dictat (but I could be wrong).

Original author: SQL Server FineBuild 1-click install and best practice configuration of SQL Server 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005. 1 Dec 2016: now over 39,000 downloads.
Disclaimer: All information provided is a personal opinion that may not match reality.
Quote: "When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist." - Archbishop Hélder Câmara
Lynn Pettis
Lynn Pettis
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24198 Visits: 37964
That's where you build a database agnostic DAL and your actual database layer is written to support the RDBMS of choice. To provide a system that performs well on both Oracle and SQL Server, for instance, you should have to separate code bases at the database layer. This allows you to code each to make the best use of the RDBMS features available.

Extra cost, probably. Better performance for the application on both systems, probably. If a customer were to change the RDBMS would you be in a better position to retain the customer, (again) probably.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
HowardW
HowardW
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1211 Visits: 9892
Lynn Pettis (8/9/2012)

That's where you build a database agnostic DAL and your actual database layer is written to support the RDBMS of choice. To provide a system that performs well on both Oracle and SQL Server, for instance, you should have to separate code bases at the database layer. This allows you to code each to make the best use of the RDBMS features available.

Extra cost, probably. Better performance for the application on both systems, probably. If a customer were to change the RDBMS would you be in a better position to retain the customer, (again) probably.



Agreed on all counts, especially when it comes to the actual application code. In terms of the basic schema design though, it's still a case of working out the closest possible fits in terms of data types and a few small sacrifices for the sake of consistent data across the platforms isn't so awful (although good luck finding consistent data types for dates/times).
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search