Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

BIT datatype and Oracle Expand / Collapse
Author
Message
Posted Wednesday, August 8, 2012 4:49 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, June 21, 2013 3:18 AM
Points: 9, 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?
Post #1341784
Posted Wednesday, August 8, 2012 8:59 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 12:08 PM
Points: 1,388, Visits: 6,262
Smallint can be used to store 0 or 1, but isn't supported in Oracle (has number datatype).
ANSI<->TSQL
ANSI<->Oracle
Post #1341938
Posted Wednesday, August 8, 2012 11:03 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Tuesday, January 28, 2014 8:15 AM
Points: 3,068, Visits: 4,639
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.
Post #1342041
Posted Thursday, August 9, 2012 12:45 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, June 21, 2013 3:18 AM
Points: 9, 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.
Post #1342419
Posted Thursday, August 9, 2012 4:23 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 9:07 AM
Points: 1,231, Visits: 9,668
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...
Post #1342496
Posted Thursday, August 9, 2012 9:29 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 5:34 AM
Points: 2,859, Visits: 3,187
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 2014, 2012, 2008 R2, 2008 and 2005. 28 July 2014: now over 30,000 downloads.
Disclaimer: All information provided is a personal opinion that may not match reality.
Concept: "Pizza Apartheid" - the discrimination that separates those who earn enough in one day to buy a pizza if they want one, from those who can not.
Post #1342765
Posted Thursday, August 9, 2012 9:36 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 9:07 AM
Points: 1,231, Visits: 9,668
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.
Post #1342770
Posted Thursday, August 9, 2012 9:53 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 5:34 AM
Points: 2,859, Visits: 3,187
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 2014, 2012, 2008 R2, 2008 and 2005. 28 July 2014: now over 30,000 downloads.
Disclaimer: All information provided is a personal opinion that may not match reality.
Concept: "Pizza Apartheid" - the discrimination that separates those who earn enough in one day to buy a pizza if they want one, from those who can not.
Post #1342786
Posted Thursday, August 9, 2012 10:10 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 2:02 PM
Points: 23,060, Visits: 31,587

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.




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)
Post #1342809
Posted Thursday, August 9, 2012 10:35 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 9:07 AM
Points: 1,231, Visits: 9,668
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).
Post #1342838
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse