Page 1 of 1

Sql to increase column size

PostPosted: Sat Jun 17, 2017 7:28 am
by BRobinsonS
I have a field in a couple tables of ProvState String(2) .
I have a request from Australia that a user needs at least String(3).
I would like to alter the field/column size to String(5) for existing databases using SQL in the code.

What would be the correct syntax using Neobook and DBPro?

Re: Sql to increase column size

PostPosted: Sat Jun 17, 2017 8:17 am
by Gaev
Brian:

Slightly different syntax depending on server brand ... details here ... http://www.1keydata.com/sql/alter-table ... olumn.html

Re: Sql to increase column size

PostPosted: Sat Jun 17, 2017 8:22 am
by Rasl
dbpExecSQL "DATABASE" "[sql]" ""

[sql]
SQL Server / MS Access:

ALTER TABLE table_name ALTER COLUMN ProvState varchar(5);


My SQL / Oracle (prior version 10G):

ALTER TABLE table_name MODIFY COLUMN ProvState datatype;

Oracle 10G and later:

ALTER TABLE table_name MODIFY ProvState datatype;

salu2

Re: Sql to increase column size

PostPosted: Sat Jun 17, 2017 9:10 am
by BRobinsonS
I am using the AccessDB of DBPro.

Re: Sql to increase column size

PostPosted: Sat Jun 17, 2017 10:31 am
by Gaev
Brian:

I am using the AccessDB of DBPro.


As per ... https://msdn.microsoft.com/en-us/librar ... =office.12).aspx ...
Code: Select all
ALTER TABLE {your Table Name here} ALTER COLUMN {your Field Name here} TEXT(5)

Re: Sql to increase column size

PostPosted: Sat Jun 17, 2017 11:21 am
by BRobinsonS
Thank you.
It works.