varchar

What's the Postgresql equivalent of string.Format("{0:s}", DateTime.Now) ?

What's the equivalent of sortable datetime/timestamp varchar in PostgreSQL? Console.WriteLine("{0:s}", DateTime.Now); sample format output: 2000-05-04T15:30:59 This works, SELECT now::varchar, output is '2009-03-25', but only for date type, wondering what's the equivalent for timestamp. Note, i know date is sortable in and of itse...

varchar(max) MS SQL Server 2000, problems?

Hi, I've inherited a asp.net website project that currently runs MS SQL 2000 as its backend. I've been doing some databases changes on a local copy of the db using MS SQL Server 2005 Express. I've create a table using varchar(max) columns. They are used to stored snippets of XHTML that are of arbitrary length. While browsing around on ...

Why does casting text as varchar without specifying a length truncate the text at 30 characters?

I was searching an MS-SQL Server 2005 database to make sure that a certain text field was always a multiple of 8 in length. When I ran the following query, I got that several rows were of length 30. But when I investigated those records, I found that they were longer than that. select distinct len(cast(textfield as varchar)) from tabl...

javascript - accessing a field of datatype varchar(max) in resultset

Within a javascript app, we're calling a sproc on SQL Server 2005 that's returning a resultset with 3 columns of type: bigint, varchar(20), and varchar(MAX). When calling the sproc and reading the results, there's no exception being thrown. When enumerating the resultset: var dbConn = DatabaseConnectionFactory.createDatabaseConnection(...

Firebird - UTF8 VarChar size

I am changing all varchar columns in our firebird database to UTF8 however I don't understand the difference in varchar size. For example, with the charset and collation set to nothing, we can set the varchar size to 255, if we set the charset and collation to UTF8, when we set the varchar to 255, it reads different values. What would ...

SQL: Why is varchar(50) the default?

When I create a new VARCHAR column in Microsoft SQL Server Manager Studio, it defaults to 50 length. Does this length have some special meaning? If theoretically I have the option to choose for a length between 30 and 70, is isn't it better to go for defaults that are power of 2 (like 32, or 64 in this case)? ...

ms sql server; varchar(MAX) vs TEXT

I just read that VARCHAR(MAX) (which can store, what, close to 2GB of char data?) is the recommended replacement for TEXT columns in 2005 and newer. My question is, if I want to search inside this column for any string ( ... WHERE COL1 LIKE '%search string%' ...) is it quicker to search a VARCHAR(MAX) using the LIKE clause, or use the TE...

varchar vs. mediumtext

Hello, I have a website that has approx 1000 different strings in a mysql database which are used to display all of the text on my website. The reason the string are stored in a database is because I'm supporting 2 different languages and need to be able to display the different languages based on the users preference (english and chin...

Can I get a list of rows with varchar values that aren't castable to datetime?

I have a legacy SQL Server 2000 database that has one column that has a date that is stored as a varchar instead of a datetime for whatever reason. I want to make a view against this data and use a datetime field instead of a varchar to make making a report against the field easier. The good news is that most of the values look like th...

What is the string length of a Guid?

I want to create a varchar folumn in SQL should contain N'guid' while guid is a generated Guid by .net (Guid.NewGuid). What is the length of the varchar I should expect from a Guid? is it a static length? Should I use nvarchar (will Guid ever use unicode chars)? varchar(Guid.Length) PS. I don't want to use SQL row guid data-type, jus...

Truncate a VARCHAR to specific length in Derby AUTOMATICALLY

How can I truncate a VARCHAR to the table field length AUTOMATICALLY in Derby using SQL? To be specific: CREATE TABLE A ( B VARCHAR(2) ); INSERT INTO A B VALUES ('1234'); would throw a SQLException: A truncation error was encountered trying to shrink VARCHAR '123' to length 2. Is there a easy way to suppress this exception? ...

Estimating the size needed for text in MySQL

When I have a text field, I generally store it as varchar. But then I encounter the issue of how do I know the limit I should place? Estimating how much text a user will type seems very imprecise. As varchar uses as much space as needed, is it better to set the limit to far greater than you estimate? Is there any disadvantage to using ...

For innodb table in MySQL, which is faster: varchar(255) or tinytext?

I am optimizing some innodb tables in MySQL, so I ran procedure analsye() to see what the recommendations were. The results recommended tinytext instead of varchar(255) for all the fields that were previously set up as varchar(255) Is there a performance gain to be had by using tinytext? I am only concerned about speed here, not size. ...

Drawback of large LIMIT of VAR-types

Is there any drawback (except allowing the value or array to grow too large) to setting the max integer size of a VARCHAR or VARRAY to a value significantly larger than actually necessary (or setting it to the max size allowed)? ...

SQL 2008 Compression

Hello, I am an intern and was asked to do some research on SQL 2008 data compression. We want to store several parts of outlook emails in a table. The problem is that we want to store the entire email body in a field, but then want to compress it. Using Char() will not store the whole body, but will allow compression... using varchar() w...

Create table trouble in MySQL 4.1

The column which defined with char type in a create table sentence is defined as varchar() It was defined as char(8) convert to varchar (8) in desc on DB. char(1) -> char(1) on same DB When it defined a table of the char type more than 2 bytes, to convert for varchar() is specifications in MySQL 4.1? ...

How can Hibernate map the SQL data-type nvarchar(max)?

I have a column in my SQL-2005 database that used to be a varchar(max), but it has been changed to an nvarchar(max). Now I need to update my hibernate mapping file to reflect the change, and this is what it used to be: <element type="text" column="Value"/> When I try to run the application, the following error appears: org.hib...

What are the optimum varchar sizes for MySQL?

How does MySQL store a varchar field? Can I assume that the following pattern represents sensible storage sizes : 1,2,4,8,16,32,64,128,255 (max) A clarification via example. Lets say I have a varchar field of 20 characters. Does MySQL when creating this field, basically reserve space for 32 bytes(not sure if they are bytes or not) but ...

oracle varchar to number

How do i convert a oracle varchar value to number eg table - exception exception_value 555 where exception_value is a varchar type I would like to test the value of exception_value column select * from exception where exception_value = 105 instead of select * from exception where exception_value = '105' ...

What is the difference between CHARACTER VARYING and VARCHAR in PostgreSQL?

John uses CHARACTER VARYING in the places where I use VARCHAR. I am a beginner, while he is an expert. This suggests me that there is something which I do not know. What is the difference between CHARACTER VARYING and VARCHAR in PostgreSQL? ...