sql-types

confusion about using types instead of gtts in oracle

て烟熏妆下的殇ゞ 提交于 2020-01-07 04:22:32
问题 I am trying to convert queries like below to types so that I won't have to use GTT: insert into my_gtt_table_1 (house, lname, fname, MI, fullname, dob) (select house, lname, fname, MI, fullname, dob from (select 'REG' house, mbr_last_name lname, mbr_first_name fname, mbr_mi MI, mbr_first_name || mbr_mi || mbr_last_name fullname, mbr_dob dob from table_1 a, table_b where a.head = b.head and mbr_number = '01' and mbr_last_name = v_last_name) c above is just a sample but complex queries are

NCHAR(1) vs BIT

和自甴很熟 提交于 2019-12-07 05:11:07
问题 I'm working under refactoring of database (SQL Server 2008) scheme and gather arguments to change NCHAR(1) columns (which keep Y|N values) to BIT . Everybody understand this is necessary and don't know why does it take place but this change affects production database so weighty arguments are required. Table keeps address catalog (up to 1m of records). First argument I found - each nchar fields take 2 bytes, each 8 bit fields - 1 byte (next 8 - additional 1 byte). What's next? Maybe some

SQL Server, nvarchar(MAX) or ntext, image or varbinary?

空扰寡人 提交于 2019-12-01 16:24:17
When should I choose one or the other? What are the implications regarding space and (full-text) indexing? BTW: I'm currently using SQL Server 2005 planing to upgrade to 2008 in the following months. Thanks Eric Z Beard The new (max) fields make it a lot easier to deal with the data from .NET code. With varbinary(max) , you simply set the value of a SqlParameter to a byte array and you are done. WIth the image field, you need to write a few hundred lines of code to stream the data into and out of the field. Also, the image/text fields are deprecated in favor of varbinary(max) and varchar(max)

SQL Server, nvarchar(MAX) or ntext, image or varbinary?

旧城冷巷雨未停 提交于 2019-12-01 15:00:46
问题 When should I choose one or the other? What are the implications regarding space and (full-text) indexing? BTW: I'm currently using SQL Server 2005 planing to upgrade to 2008 in the following months. Thanks 回答1: The new (max) fields make it a lot easier to deal with the data from .NET code. With varbinary(max) , you simply set the value of a SqlParameter to a byte array and you are done. WIth the image field, you need to write a few hundred lines of code to stream the data into and out of the

SQL function return-type: TABLE vs SETOF records

那年仲夏 提交于 2019-11-30 07:59:41
问题 What's the difference between a function that returns TABLE vs SETOF records , all else equal. CREATE FUNCTION events_by_type_1(text) RETURNS TABLE(id bigint, name text) AS $$ SELECT id, name FROM events WHERE type = $1; $$ LANGUAGE SQL STABLE; CREATE FUNCTION events_by_type_2(text) RETURNS SETOF record AS $$ SELECT id, name FROM events WHERE type = $1; $$ LANGUAGE SQL STABLE; These functions seem to return the same results. See this SQLFiddle. 回答1: When returning SETOF record the output

SQL function return-type: TABLE vs SETOF records

浪子不回头ぞ 提交于 2019-11-29 05:29:49
What's the difference between a function that returns TABLE vs SETOF records , all else equal. CREATE FUNCTION events_by_type_1(text) RETURNS TABLE(id bigint, name text) AS $$ SELECT id, name FROM events WHERE type = $1; $$ LANGUAGE SQL STABLE; CREATE FUNCTION events_by_type_2(text) RETURNS SETOF record AS $$ SELECT id, name FROM events WHERE type = $1; $$ LANGUAGE SQL STABLE; These functions seem to return the same results. See this SQLFiddle . When returning SET OF record the output columns are not typed and not named. Thus this form can't be used directly in a FROM clause as if it was a

Create a table of two types in PostgreSQL

荒凉一梦 提交于 2019-11-28 13:05:10
I have created two types: Create Type info_typ_1 AS ( Prod_id integer, category integer); Create Type movie_typ AS( title varchar(50), actor varchar(50), price float); And I want to create a table that consists of these two types. I know that for a table that consists of one type, it's: CREATE TABLE Table1 of type1 ( primary key(prod_id) ); Is there any way to do that for the two types I created above? What I tried doing(which is wrong), is creating a third type that contains the first two: Create Type info_ AS ( info info_typ_1, movie movie_typ); and then creating the table: CREATE TABLE

Create a table of two types in PostgreSQL

我怕爱的太早我们不能终老 提交于 2019-11-27 07:29:05
问题 I have created two types: Create Type info_typ_1 AS ( Prod_id integer, category integer); Create Type movie_typ AS( title varchar(50), actor varchar(50), price float); And I want to create a table that consists of these two types. I know that for a table that consists of one type, it's: CREATE TABLE Table1 of type1 ( primary key(prod_id) ); Is there any way to do that for the two types I created above? What I tried doing(which is wrong), is creating a third type that contains the first two:

What is the string length of a GUID?

那年仲夏 提交于 2019-11-27 05:51:59
I want to create a varchar column in SQL that should contain N'guid' while guid is a generated GUID by .NET ( Guid.NewGuid ) - class System.Guid. 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 characters)? varchar(Guid.Length) PS. I don't want to use a SQL row guid data-type. I am just asking what is Guid.MaxLength . It depends on how you format the Guid: Guid.NewGuid().ToString() => 36 characters (Hyphenated) outputs: 12345678-1234-1234-1234-123456789abc Guid.NewGuid().ToString("D") => 36 characters

Set decimal(16, 3) for a column in Code First Approach in EF4.3

放肆的年华 提交于 2019-11-26 22:20:59
How can I do this : private decimal _SnachCount; [Required] [DataType("decimal(16 ,3")] public decimal SnachCount { get { return _SnachCount; } set { _SnachCount = value; } } private decimal _MinimumStock; [Required] [DataType("decimal(16 ,3")] public decimal MinimumStock { get { return _MinimumStock; } set { _MinimumStock = value; } } private decimal _MaximumStock; [Required] [DataType("decimal(16 ,3")] public decimal MaximumStock { get { return _MaximumStock; } set { _MaximumStock = value; } } After generating the database by this part of my model , these three columns type are decimal(18,2)