Reputation: 33
it is possible to do a select that brings a string column with a restricted number of characters? For example, I have a column that has records with 10 and 15 characters, I want only has 10 characters.
Upvotes: 1
Views: 98
Reputation: 169324
Use substr
. Tested example here: http://sqlfiddle.com/#!4/9b800/1
create table t (v varchar(50));
insert into t values ('this is a test of the substr fn');
insert into t values ('this is another test of the substr fn');
select
substr(v,1,10) restricted_output,
v unrestricted_output
from t
Resultset:
RESTRICTED_OUTPUT UNRESTRICTED_OUTPUT this is a this is a test of the substr fn this is an this is another test of the substr fn
Upvotes: 3
Reputation: 35323
Your question is a big vague. Are you saying a field in a table allows X characters (15,30, whatever) and you only want those records with a Length of 10? if so... the following would work substituting table name and yourField for the values in your system.
Select * from tableName where length(yourField) = 10
If however you're after all table columns having a length of 10. Look at All_tab_cols view for a list of table/columns and field sizes.
Upvotes: 2