Thank you for the reply, Martin.

I wasn't looking for the sum of all lengths, just the length of each individual 
column, but I think you answered my question anyway--that it can't be done 
without naming each column.

That's fine, I just wanted to make sure that I wasn't naming the columns 
needlessly.

Just to confirm, the following is the only practical way to get the length of 
each column in a table:

Select Length(col_1)
,Length(col_2)
,Length(col_3)
. 
. 
. 
,Length(col_n)
FROM myTable;

Correct?

--
Bill Drago
Senior Engineer
L3 Narda-MITEQ
435 Moreland Road
Hauppauge, NY 11788
631-272-5947 / William.Drago at L-3COM.com


> -----Original Message-----
> From: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-
> users-bounces at mailinglists.sqlite.org] On Behalf Of Martin Engelschalk
> Sent: Monday, June 01, 2015 11:23 AM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] How to get length of all columns in a table
>
> Hi,
>
> the length funktion takes an expression as an argument, for example a
> column name like
>
> select length(MyColumn) from MyTable;
>
> Offhand, I can think of no way to calculate the sum of the lengths of
> the contents of all columns of a table without naming all the columns.
> There are two ways:
>
> select length(MyColumn1 || MyColumn2 || MyColumn3) from MyTable; or
> select length(MyColumn1) + length (MyColumn2) + length (MyColumn3) from
> MyTable;
>
> Also, you will probably want to watch for columns with null values. So
> this will work:
>
> select coalesce(length(MyColumn1),0) + coalesce(length (MyColumn2),0) +
> coalesce(length (MyColumn3),0) from MyTable;
>
> HTH
> Martin
>
>
> Am 01.06.2015 um 17:12 schrieb Drago, William @ CSG - NARDA-MITEQ:
> > All,
> >
> > What is the correct syntax for getting the length of all columns in a
> > table? I tried
> >
> > SELECT Length(*) FROM myTable;
> >
> > and
> >
> > Length(SELECT * FROM myTable);
> >
> > Neither one of those works, and I can't find anything on line.
> >
> > Thanks,
> > --
> > Bill Drago
> > Senior Engineer
> > L3 Narda-MITEQ<http://www.nardamicrowave.com/>
> > 435 Moreland Road
> > Hauppauge, NY 11788
> > 631-272-5947 /
> > William.Drago at L-3COM.com<mailto:William.Drago at L-3COM.com>
> >
> >
> > CONFIDENTIALITY, EXPORT CONTROL AND DISCLAIMER NOTE:This e-mail and
> any attachments are solely for the use of the addressee and may contain
> information that is privileged or confidential. Any disclosure, use or
> distribution of the information contained herein is prohibited. In the
> event this e-mail contains technical data within the definition of the
> International Traffic in Arms Regulations or Export Administration
> Regulations, it is subject to the export control laws of the
> U.S.Government. The recipient should check this e-mail and any
> attachments for the presence of viruses as L-3 does not accept any
> liability associated with the transmission of this e-mail. If you have
> received this communication in error, please notify the sender by reply
> e-mail and immediately delete this message and any attachments.
> > _______________________________________________
> > sqlite-users mailing list
> > sqlite-users at mailinglists.sqlite.org
> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
CONFIDENTIALITY, EXPORT CONTROL AND DISCLAIMER NOTE:This e-mail and any 
attachments are solely for the use of the addressee and may contain information 
that is privileged or confidential. Any disclosure, use or distribution of the 
information contained herein is prohibited. In the event this e-mail contains 
technical data within the definition of the International Traffic in Arms 
Regulations or Export Administration Regulations, it is subject to the export 
control laws of the U.S.Government. The recipient should check this e-mail and 
any attachments for the presence of viruses as L-3 does not accept any 
liability associated with the transmission of this e-mail. If you have received 
this communication in error, please notify the sender by reply e-mail and 
immediately delete this message and any attachments.

Reply via email to