Groupe_concat max length in postgres? - postgresql-9.5

is there a way to set, like in the SQL example below, groupe_concat max length in Postgres?
SET group_concat_max_len=15000000;
many thanks.

No there is no such configuration parameter.
The maximum length of the result of string_agg() (or any other string concatenation) is limited by the maximum length of a text value in Postgres which is 1GB.

Related

Minimum length of double value in a column in Impala table

I am trying to find the minimum length by getting the length of each values in a column (double) in a table and running a min function on top of it to get the minimum length.
This works well when the column is a string type but the 'length' function does not work for double datatype in impala, what is the other way to address this?
min(length(columnname))
All double columns are 8 bytes, as explained in the documentation. LENGTH() is a string function and it doesn't really make sense on a numeric value (although you can convert to a string and then measure the length).

how to format int number output with thousand separator in hive sql

Do you know how to format the output of a number in hive with thousand separator? For example:
data:146452664
output:146,452,664
I use this in Teradata, but don't know how to achieve in Hive.
cast(cast(cast(number as integer) as format'ZZZ,ZZZ,ZZZ,ZZ9') as char(11))
Use the format_number() function.
select format_number(146452664,0)
The first argument is the number and second is the number of decimal places to round.If D is 0, the result has no decimal point.

How to get maximum size used by a string in Hive?

I want to know the maximum length a particular string column is taking.
I tried taking the approached mentioned here :
how to get the max size used by a field in table but did not work in Hive
but that did not work in Hive.
In that example they use len, use length instead:
select max(length(mycolumn)) from mytable;
This works fine in hive QL.
multiple ways to check length of column in where clause as well:
select max(length(column_name)),min(length(column_name)) from table_name where length(column_name)<15
Here, checked column length with max and min values. Also use where clause if checking column length lesser than 15

Getting max length of a varchar(max) from syscolumns in sql server

select c.name, t.name, c.length
from syscolumns c
c.length gives me -1 for any column that has max e.g varchar(max)
What should I do to get length ?
The data type of length on sys.columns is a smallint, whilst the max length of the varchar(max) is 2.1 billion, so it has a problem holding the real length. The -1 is in the documentation for denoting a varchar(max), varbinary(max), nvarchar(max) and xml.
http://msdn.microsoft.com/en-us/library/ms176106(v=sql.100).aspx
If you really need the number, then you would need a case statement to replace -1 with (2^31)-1
If you want to get the length of physical data, then you need to max / min / avg the appropriate lengths on the tables with the data on it based on what you need that information for. When querying the length of the field, DATALENGTH returns the bytes used, LEN returns the characters count.
-1 means that the column is of type max. The max length is then the max type, as per documentation. MAX types have a maximum length of 2GB if the FILESTREAM attribute is not specified, or a max size limited only by the disk size available:
The sizes of the BLOBs are limited only by the volume size of the file
system. The standard varbinary(max) limitation of 2-GB file sizes does
not apply to BLOBs that are stored in the file system.
Therefore your question really doesn't have an answer. You can ask what is the actual size of any actual in the table value, using DATALENGTH.
As seen HERE:
Variable-length, non-Unicode character data. n can be a value from 1 through 8,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size is the actual length of data entered + 2 bytes. The data entered can be 0 characters in length. The ISO synonyms for varchar are char varying or character varying.
In other words, max = 2147483647 bytes if all the possible space is occupied..
The length of the column in each row could vary. Hence the result of -1

How to make use of SQL (Oracle) to count the size of a string?

i was wondering if there was a function in Oracle to count the number of character size in Oracle, i.e. given "Burger", the SQL returns 6.
i.e. select XXX('Burger') from DUAL;
You can use LENGTH() for CHAR / VARCHAR2 and DBMS_LOB.GETLENGTH() for CLOB. Both functions will count actual characters (not bytes).
See the linked documentation if you do need bytes.
you need length() function
select length(customer_name) from ar.ra_customers
The length function will do it. See http://www.techonthenet.com/oracle/functions/length.php
Regarding to Your example
select length('Burger') from dual;
I hope this will help :)