473,692 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

int1?

CSN
Is there any date type that can be used for 0-255
values? Like an "int1" or byte column.

CSN

_______________ _______________ ____
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #1
35 4338
CSN wrote:
Is there any date type that can be used for 0-255
values? Like an "int1" or byte column.


You can use a smallint with constraint.

HTH
Shridhar
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #2
On Thu, 2003-10-09 at 02:16, CSN wrote:
Is there any date type that can be used for 0-255
values? Like an "int1" or byte column.


An int2 with a constraint on it.

--
-----------------------------------------------------------------
Ron Johnson, Jr. ro***********@c ox.net
Jefferson, LA USA

"Fear the Penguin!!"
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 12 '05 #3
> Is there any date type that can be used for 0-255
values? Like an "int1" or byte column.


A SMALLINT is two bytes on disk, use "char" instead. This is a hidden
goodie in PostgreSQL and one that I wish was exposed via a more
conventional syntax (*hint hint*).

http://developer.postgresql.org/docs...-SPECIAL-TABLE

-sc

--
Sean Chittenden

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #4
On Thu, 2003-10-09 at 03:19, Sean Chittenden wrote:
Is there any date type that can be used for 0-255
values? Like an "int1" or byte column.


A SMALLINT is two bytes on disk, use "char" instead. This is a hidden
goodie in PostgreSQL and one that I wish was exposed via a more
conventional syntax (*hint hint*).

http://developer.postgresql.org/docs...-SPECIAL-TABLE


Wouldn't that be, though, a signed byte? The OP wants unsigned.

--
-----------------------------------------------------------------
Ron Johnson, Jr. ro***********@c ox.net
Jefferson, LA USA

The purpose of the military isn't to pay your college tuition or
give you a little extra income; it's to "kill people and break
things".
Surprisingly, not everyone understands that.
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #5
> http://developer.postgresql.org/docs...-SPECIAL-TABLE
Is it unsafe practice to use the datatype "name" for
attributes that hold table or column names etc ?

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #6

On Thu, 9 Oct 2003, Sean Chittenden wrote:
Is there any date type that can be used for 0-255
values? Like an "int1" or byte column.
A SMALLINT is two bytes on disk, use "char" instead. This is a hidden


However "char" has some serious deficiencies IIRC, such as the fact that
there's no int<->"char" casts and it's standard I/O format is characters.
You can use ascii and chr to get around some of that, but it's ugly.
goodie in PostgreSQL and one that I wish was exposed via a more
conventional syntax (*hint hint*).


If we were going to do that I think we'd be better off making a new type
and leaving "char" alone.
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #7
> > > Is there any date type that can be used for 0-255 values? Like
an "int1" or byte column.
A SMALLINT is two bytes on disk, use "char" instead. This is a hidden


However "char" has some serious deficiencies IIRC, such as the fact
that there's no int<->"char" casts and it's standard I/O format is
characters. You can use ascii and chr to get around some of that,
but it's ugly.


*nods* I have explicit casts everywhere when dealing with "char" and
it's far from being elegant or clean.
goodie in PostgreSQL and one that I wish was exposed via a more
conventional syntax (*hint hint*).


If we were going to do that I think we'd be better off making a new
type and leaving "char" alone.


You won't hear any disagreements from me on this one. I've
sufficiently abused "char" as a 1 byte storage field and would love to
see an int1 or tinyint datatype added to cover this situation. -sc

--
Sean Chittenden

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 12 '05 #8
On Thu, 2003-10-09 at 12:54, Sean Chittenden wrote:
> Is there any date type that can be used for 0-255 values? Like
> an "int1" or byte column.

A SMALLINT is two bytes on disk, use "char" instead. This is a hidden


However "char" has some serious deficiencies IIRC, such as the fact
that there's no int<->"char" casts and it's standard I/O format is
characters. You can use ascii and chr to get around some of that,
but it's ugly.


*nods* I have explicit casts everywhere when dealing with "char" and
it's far from being elegant or clean.
goodie in PostgreSQL and one that I wish was exposed via a more
conventional syntax (*hint hint*).


If we were going to do that I think we'd be better off making a new
type and leaving "char" alone.


You won't hear any disagreements from me on this one. I've
sufficiently abused "char" as a 1 byte storage field and would love to
see an int1 or tinyint datatype added to cover this situation. -sc


http://www.postgresql.org/docs/7.3/s...atedomain.html
CREATE DOMAIN domainname [AS] data_type
[ DEFAULT default_expr ]
[ constraint [, ... ] ]

where constraint is:

[ CONSTRAINT constraint_name ]
{ NOT NULL | NULL }

test1=# create domain d_tinyint as smallint constraint chk_tinyint CHECK (smallint between 0 and 255);
ERROR: DefineDomain: CHECK Constraints not supported

So, how would I create a domain that limits a smallint?

--
-----------------------------------------------------------------
Ron Johnson, Jr. ro***********@c ox.net
Jefferson, LA USA

"You can either have software quality or you can have pointer
arithmetic, but you cannot have both at the same time."
Bertrand Meyer
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #9
On Thu, Oct 09, 2003 at 14:28:57 -0500,
Ron Johnson <ro***********@ cox.net> wrote:

http://www.postgresql.org/docs/7.3/s...atedomain.html
CREATE DOMAIN domainname [AS] data_type
[ DEFAULT default_expr ]
[ constraint [, ... ] ]

where constraint is:

[ CONSTRAINT constraint_name ]
{ NOT NULL | NULL }

test1=# create domain d_tinyint as smallint constraint chk_tinyint CHECK (smallint between 0 and 255);
ERROR: DefineDomain: CHECK Constraints not supported

So, how would I create a domain that limits a smallint?


You need to use 7.4. In 7.3 you couldn't use check constraints with domains.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
1235
by: Xiangliang Meng | last post by:
The fragment code: #include <iostream> using namespace std; class Integer { int i; public: Integer() : i(0) {};
7
6706
by: Tweaxor | last post by:
I stuck with exerise in a Learning C book that I got. If I have the numbers as input. How can I determine which of the three is the smallest number, largest number and the range. Or would it be simpler to just find the range of the three numbers. Thanks in advance :D
1
2546
by: Primillo | last post by:
'Full source 'Insert, delete and update don't work Public Class WebForm1 Inherits System.Web.UI.Page Protected WithEvents Button1 As System.Web.UI.WebControls.Button Protected WithEvents Button2 As System.Web.UI.WebControls.Button Protected WithEvents Button3 As System.Web.UI.WebControls.Button
6
1623
by: AMDRIT | last post by:
Hello folks, I appologize for the cross post, but I really need an answer on this: I do not think that I am seeing the whole picture here. I would like to create a windows service and a management console, using Visual Basic 2003. The windows service part, I think, is easy enough. I am more concerned with the remoting aspect of the project. Below is the general idea of my approach, please correct my where I am wrong.
9
2575
by: Greg Strong | last post by:
Hello All, What is the maximum length of an ODBC pass through query? Things work fine with the code except when I try to create a view which is pretty complex in Oracle. I'm using a DSN provided with the Oracle Express Edition and using Access 2k2 as the front-end. When I debug print the SQL and paste it into SQLplus it works fine. The length of the debug print that works is 1988 characters. Since the exact same code works with...
6
1278
by: =?Utf-8?B?ZGljazIz?= | last post by:
I am just a beginner coding in VB6. I am trying to write a simple code to add 2 numbers together and put the answer in a text box I have one textbox open to accept each number, a textbox to accept the answer and a button where I am adding this code Dim intNumber1 As Integer Dim intNumber2 As Integer Dim intAnswer As Integer intAnswer = intNumber1 + intNumber2 txtAnswer.Text = intAnswer How come I keep getting 0 as an anwer
11
16519
by: ITprogramer17 | last post by:
Hi... How to add 4+6 when you use two textbox, the first textbox is for the input and the other one if for the output..
6
47668
by: Author | last post by:
I have class BaseClass { public BaseClass(string s1, string s2) { this.S1 = s1; this.S2 = s2; } public string S1 { get; set;}
0
8611
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8811
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8810
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7635
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5822
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4327
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
1962
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.