Questions tagged [sqldatatypes]

Concerns data types used with SQL.

Concerns data types used with SQL.

References

1229 questions
2829
votes
39 answers

Should I use the datetime or timestamp data type in MySQL?

Would you recommend using a datetime or a timestamp field, and why (using MySQL)? I'm working with PHP on the server side.
koni
  • 38,096
  • 13
  • 51
  • 77
1273
votes
13 answers

Which MySQL data type to use for storing boolean values

Since MySQL doesn't seem to have any 'boolean' data type, which data type do you 'abuse' for storing true/false information in MySQL? Especially in the context of writing and reading from/to a PHP script. Over time I have used and seen several…
Beat
375
votes
11 answers

How do you create a yes/no boolean field in SQL server?

What is the best practice for creating a yes/no i.e. Boolean field when converting from an access database or in general?
leora
  • 163,579
  • 332
  • 834
  • 1,328
306
votes
12 answers

Best data type to store money values in MySQL

I want to store many records in a MySQL database. All of them contains money values. But I don't know how many digits will be inserted for each one. Which data type do I have to use for this purpose? VARCHAR or INT (or other numeric data types)?
Mohammad Saberi
  • 11,594
  • 23
  • 65
  • 123
292
votes
4 answers

SQL Server Text type vs. varchar data type

I have variable length character data and want to store in SQL Server (2005) database. I want to learn some best practices about how to choose TEXT SQL type or choose VARCHAR SQL type, pros and cons in performance/footprint/function.
George2
  • 42,353
  • 103
  • 307
  • 447
284
votes
11 answers

Is there any boolean type in Oracle databases?

Is there any Boolean type in Oracle databases, similar to the BIT datatype in Ms SQL Server?
Peder
  • 2,841
  • 2
  • 13
  • 3
282
votes
6 answers

What is the difference between varchar and varchar2 in Oracle?

What is the difference between varchar and varchar2?
hrishi
  • 2,885
  • 4
  • 17
  • 10
218
votes
9 answers

Best data type for storing currency values in a MySQL database

What is the best SQL data type for currency values? I'm using MySQL but would prefer a database independent type.
Brian Fisher
  • 21,783
  • 15
  • 72
  • 81
204
votes
4 answers

MySql: Tinyint (2) vs tinyint(1) - what is the difference?

I knew boolean in mysql as tinyint (1). Today I see a table with defined an integer like tinyint(2), and also others like int(4), int(6) ... What does the size means in field of type integer and tinyint ?
realtebo
  • 19,593
  • 31
  • 85
  • 151
191
votes
16 answers

How do I check if a SQL Server text column is empty?

I am using SQL Server 2005. I have a table with a text column and I have many rows in the table where the value of this column is not null, but it is empty. Trying to compare against '' yields this response: The data types text and varchar are…
atoumey
  • 2,296
  • 2
  • 19
  • 16
146
votes
8 answers

Boolean Field in Oracle

Yesterday I wanted to add a boolean field to an Oracle table. However, there isn't actually a boolean data type in Oracle. Does anyone here know the best way to simulate a boolean? Googling the subject discovered several approaches Use an…
Eli Courtwright
  • 164,889
  • 61
  • 203
  • 255
131
votes
6 answers

Is there any difference between DECIMAL and NUMERIC in SQL Server?

Is there any difference between DECIMAL and NUMERIC data types in SQL Server? When should I use DECIMAL and when NUMERIC?
Dhanapal
  • 13,343
  • 35
  • 105
  • 141
125
votes
5 answers

Appropriate datatype for holding percent values?

What is the best datatype for holding percent values ranging from 0.00% to 100.00%?
User
  • 49,320
  • 65
  • 164
  • 234
112
votes
12 answers

How to get a list column names and datatypes of a table in PostgreSQL?

How can I get a list of column names and datatypes of a table in PostgreSQL using a query?
Pratik
  • 1,644
  • 2
  • 18
  • 28
108
votes
4 answers

What data type should be use for timestamp in DynamoDB?

I am new to DynamoDB. I wish to create a table which using DeviceID as the hash key, Timestamp as my range key and some data. { DeviceID: 123, Timestamp: "2016-11-11T17:21:07.5272333Z", X: 12, Y: 35 } In SQL, we can use datetime type for Timestamp,…
Dennis
  • 2,860
  • 4
  • 23
  • 37
1
2 3
81 82