New answers tagged

0

change timestamp to char(19) String comparison is more streamlined and accurate that comparing a timestamp that may/may not include taking timezone into account. As a super bizzare example, see the StackOverflow post from Jon Skeet. tinyint to ENUM (I noticed it's overzealous with ENUMS in general) TINYINT is a integer with the range -128 to 127 ...


2

Your parameter _source in the added MWE is not referenced anywhere. The identifier source in the function body has no leading underscore and is interpreted as constant table name independently. More importantly, it would not work like this anyway. SQL only allows to parameterize values in DML statements. Details in this related answer: Error when setting ...


3

Explanation I'm going to step through the multiple layers of misunderstandings one by one - arriving at a simple, secure solution. 0. The reason why overlay is escaped is not because it's a function name, but because it's a reserved word. Also, overlay() is not a "PL/pgSQL function" (nor PL/pgSQL keyword), it's a standard SQL function built into the ...


1

The only way I could think was to wrap the call to the format function in a translate as follows: RETURN translate(format('%I_new',old_name),'"',''); This post processes the output of the format and strips the " characters out. I don't know if anybody has a more elegant solution. I thought of btrim, rtrim etc...but it would need a call to each.


4

1) The purpose is to provide a logical representation of a data entity (coordinates for example or a path) that can be indexed and queried in Postgresql. And also postgresql can understand this datatype. 2) Technically it's possible but you're better of storing it as two float so you can filter on them. It's never recommended to try to outsmart database ...


24

Should I always use (n)varchar(max) for text columns? No. For SQL Server, the max data types should only be specified when there is no alternative. One should instead choose the correct base type (varchar or nvarchar) and specify an explicit maximum length that is appropriate to the data to be stored. Physical storage is identical whether the column is ...


7

This is going to read like a paranoid's answer, but there aren't only storage and performance considerations. The database itself doesn't control its clients, and clients can't be assumed to always securely insert user input - even if a database is designed to be used only with a .net application that uses Entity Framework to encapsulate transactions and ...


0

DATETIME vs TIMESTAMP -- If everything is always in the same timezone, then it does not matter. Across timezones, it may matter. DATETIME is like taking a picture of a clock; TIMESTAMP is an instant in the universe. If I insert noon in a DATETIME, it will say noon for you wherever you are. But inserting noon into a TIMESTAMP will show up differently on ...


1

This is all IMHO: •table entry created and updated: date or timestamp? Why? With date isnt it easier to display and sort on the frontend? Use a timestamp - better for multiple mods in a given day. •Entry title - VARCHAR or text? You're not going to lose much with a text over VARCHAR, but I think that VARCHAR is the reasonable choice. •Entry body - I ...


4

It is truncating because the replacement_value parameter is being converted to the same data type as the check_expression. From https://msdn.microsoft.com/en-us/library/ms184325.aspx ISNULL ( check_expression , replacement_value ) replacement_value must be of a type that is implicitly convertible to the type of check_expresssion. Return Types ...



Top 50 recent answers are included