I have two fields i need to increment the character limit on. I're read through the documentation and to my surprise i found no option for it. Is it possible to do? If not, how should i go about solving this?
I could drop the column and re-create it with the correct properties, but i don't want to loose any data in the database.
In generic terms, you use the ALTER TABLE command followed by the table name, then the MODIFY command followed by the column name and new type and size. Here is an example: ALTER TABLE tablename MODIFY columnname VARCHAR(20) ; The maximum width of the column is determined by the number in parentheses.
In this case, you need to use ALTER TABLE statement to increase column size. ALTER TABLE table_name MODIFY column_name varchar(new_length); In the above command, you need to specify table_name whose column you want to modify, column_name of column whose length you want to change, and new_length, new size number.
SQL - Modify Column Data Type and SizeALTER TABLE Employee ALTER COLUMN FirstName VARCHAR(50); The following will change the size in the Oracle database. ALTER TABLE Employee MODIFY (FirstName VARCHAR2(50)); The following will change the size in the PostgreSQL database.
You can use the ALTER table command to change the length of a varchar column. You can increase the length of a varchar column to a maximum size of 64,000.
For Laravel 4
DB::update('ALTER TABLE `my_table` MODIFY `my_column` VARCHAR(<new length>)');
Use Raw Queries:
/**
* Make changes to the database.
*
* @return void
*/
public function up()
{
DB::query('ALTER TABLE mytable MODIFY mycolumn VARCHAR(new-length)');
}
/**
* Revert the changes to the database.
*
* @return void
*/
public function down()
{
DB::query('ALTER TABL mytable MODIFY mycolumn VARCHAR(old-length)');
}
Replace mytable
, mycolumn
, new-length
and old-length
.
For Laravel 5+ replace DB::query
with DB::statement
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With