column-types

MySQL “binary” vs “char character set binary”

ぃ、小莉子 提交于 2020-01-22 13:46:07
问题 What's the difference between binary(10) vs char(10)character set binary ? And varbinary(10) vs varchar(10)character set binary ? Are they synonymous in all MySQL engines? Is there any gotcha to watch out for? 回答1: There isn't a difference. However, there is a caveat if you're storing a string. If you only want to store a byte array or other binary data such as a stream or file then use the binary type as that is what they are meant for. Quote from the MySQL manual: The use of CHARACTER SET

How To Convert The DataTable Column type?

房东的猫 提交于 2020-01-10 06:04:14
问题 I am trying to implement: dtGroupedBy.Compute("sum(POWER)",dvv.RowFilter); It results of an error: Invalid usage of aggregate function Sum() and Type: String. How would we convert it to its column type ?? 回答1: Compute method supports expressions and they support the CONVERT function that you could use inside of the expression. For example, you could calculate sum of the column like MyDataTable.Compute("Sum(Convert(your column name, 'Data Type'))") 回答2: It will depend on how you've created the

How To Convert The DataTable Column type?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-10 06:03:03
问题 I am trying to implement: dtGroupedBy.Compute("sum(POWER)",dvv.RowFilter); It results of an error: Invalid usage of aggregate function Sum() and Type: String. How would we convert it to its column type ?? 回答1: Compute method supports expressions and they support the CONVERT function that you could use inside of the expression. For example, you could calculate sum of the column like MyDataTable.Compute("Sum(Convert(your column name, 'Data Type'))") 回答2: It will depend on how you've created the

How to change a column without dropping a table in SQL 2008

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 08:39:59
问题 Why does SQL 2008 all of a sudden want to drop my tables when I go to change the column type from say int to real? This never happened in SQL 2005 to my knowledge. Any insight would be helpful please. 回答1: In SQL Server 2008, go to Tools >> Options. In the little window, click "Designer". Uncheck "Prevent saving changes that require ..." ===== Edited on Sept 4th, 2015. I have added this answer here a long, long time ago describing the way I would solve the situation described on the question

SQL Server datatype for DB2 column “Char() for BIT Data”

时间秒杀一切 提交于 2019-12-13 04:17:21
问题 I googled but failed to find an answer for the following question. I have a DB2 database column of datatype “Char(100) for BIT Data“. It stores encrypted value of employee ID. I need to store this data in SQL Server . What should be the datatype for this column in SQL Server? Is there any formatting needed before inserting into SQL Server? 回答1: The column in your DB2 table is an ordinary character string, except that the for BIT Data part tells DB2 to treat that string as arbitrary binary

Change column type without losing data

无人久伴 提交于 2019-12-03 09:28:53
问题 I am working on an SQL Database, I have a column named "Price". When the database was created the column "Price" was set to NVARCHAR I need to change its type to decimal(18, 2) without losing the data in the database. This should be done by an SQL Script I thought of creating a new column, moving the data to it, remove the old column, and then rename the newly created column. Can someone help me with an example on how to do this? Also is there a function in SQL to Parse string to decimal?

Change column type without losing data

限于喜欢 提交于 2019-12-02 22:28:14
I am working on an SQL Database, I have a column named "Price". When the database was created the column "Price" was set to NVARCHAR I need to change its type to decimal(18, 2) without losing the data in the database. This should be done by an SQL Script I thought of creating a new column, moving the data to it, remove the old column, and then rename the newly created column. Can someone help me with an example on how to do this? Also is there a function in SQL to Parse string to decimal? Thanks You don't need to add a new column two times, just remove the old one after updating the new one:

How to change a column without dropping a table in SQL 2008

回眸只為那壹抹淺笑 提交于 2019-12-02 16:34:11
Why does SQL 2008 all of a sudden want to drop my tables when I go to change the column type from say int to real? This never happened in SQL 2005 to my knowledge. Any insight would be helpful please. In SQL Server 2008, go to Tools >> Options. In the little window, click "Designer". Uncheck "Prevent saving changes that require ..." ===== Edited on Sept 4th, 2015. I have added this answer here a long, long time ago describing the way I would solve the situation described on the question above. Since then, users on the threads below have exposed several concerns on doing things the way I

Adding foreign key of type char in mysql

混江龙づ霸主 提交于 2019-12-01 05:32:05
问题 i got a problem adding a foreign key in mysql (using phpmyadmin). ALTER TABLE `production_x_country` ADD FOREIGN KEY (`country`) REFERENCES `pmdb_0.3.12`.`countries`(`iso_3166_1`) ON DELETE CASCADE ON UPDATE CASCADE; #1215 - Cannot add foreign key constraint based on some research and tests i've come to the conclusion that CHAR (that production_x_country . country field) is no valid foreign key field type - though i did not find any hint to that assumption in the mysql docs. if i change the

What is the best column type for URL?

纵饮孤独 提交于 2019-11-30 00:19:39
What is the best column type for a URL field for SQL Server? Type: VARCHAR or NVARCHAR? Length ? Similar question for MySQL . If you are prepared to always URL encode your URLs before you store them (an example turned up by Google was 中.doc URL encoding to %E4%B8%AD.doc) then you are safe sticking with varchar. If you want the non-ASCII characters in your URLs to remain readable in the database then I'd recommend nvarchar. If you don't want to be caught out, then go for nvarchar. Since IE (the most restrictive of the mainstream browsers) doesn't support URLs longer than 2083 characters, then