This question already has answers here:
How can I modify the size of column in a MySQL table?
(3 answers)
How do I change the data type for a column in MySQL?
(9 answers)
Closed 8 years ago.
How to change the type of a column in SQL. For example the current type is char(2) I would like to make it char(20)?
ALTER TABLE test
ALTER COLUMN name char(20)
for MySql try:
ALTER TABLE test
MODIFY COLUMN name char(20)
Related
This question already has answers here:
CHECK constraint in MySQL is not working
(8 answers)
Closed 2 years ago.
i've created this table in SQL
CREATE TABLE product (
code CHAR(7) NOT NULL,
name VARCHAR(30) NOT NULL,
Description VARCHAR(500) NOT NULL,
cost DOUBLE UNSIGNED NOT NULL,
PRIMARY KEY (code),
check(substring(code,1,3) like '%[a-z]%'
and substring(code,4,4) like '%[0-9]%'),
);
the value 'code' must consist of 3 characters and 4 numbers, but it doesn't work. what's wrong in the check?
the value 'code' must consist of 3 characters and 4 numbers, but it doesn't work. what's wrong in the check?
Use regular expressions:
check (code regexp '^[A-Z]{3}[0-9]{4}$')
MySQL does not extend the definition of LIKE to include character classes. It has real regular expression support.
This question already has answers here:
MySQL: Error Code: 1118 Row size too large (> 8126). Changing some columns to TEXT or BLOB
(33 answers)
Row size too large error in mysql create table query
(8 answers)
Change limit for "Mysql Row size too large"
(19 answers)
Closed 3 years ago.
When I alter my table, I get an error:
1118 - Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. This includes storage overhead,
check the manual. You have to change some columns to TEXT or BLOBs
I've tried everything I could possibly think, please help.
ALTER TABLE property_rs_1
ADD `LA3_PhoneNumber3Ext` varchar(5) DEFAULT NULL COMMENT 'LA3Agent Phone3 Extension',
ADD `LA3_PhoneNumber4Desc` varchar(5) DEFAULT NULL COMMENT 'LA3AgentPhone4Description',
ADD `LA3_PhoneNumber4CountryCodeId` varchar(50) DEFAULT NULL COMMENT 'LA3Agent Phone4 CountryId',
ADD `LA3_PhoneNumber4` varchar(30) DEFAULT NULL COMMENT 'LA3Agent Phone4 Number',
ADD `LA3_PhoneNumber4Ext` varchar(5) DEFAULT NULL COMMENT 'LA3Agent Phone4 Extension'
This question already has answers here:
How can I modify the size of column in a MySQL table?
(3 answers)
Closed 3 years ago.
What would be the DDL syntax for changing a MySQL column name from int(10) to int(11)?
I've done a number of searches using DDL, int(10) and int(11) like this but I've not found any syntax examples.
The current migration is failing because an int(11) is being used as a foreign key referencing an int(10)
I realise I can do this in a GUI. I'm looking to push this change into a migration script for Django.
This was marked as a duplicate because another answer generally solved the issue.
I was searching specifically for changing int(10) to int(11). More to the point ... the question marked as a possible duplicate did not come up with the searches I was making.
A simple ALTER TABLE:
ALTER TABLE yourtable MODIFY COLUMN yourcolumn INT(11)
Demo on dbfiddle
This question already has answers here:
What is the size of column of int(11) in mysql in bytes?
(11 answers)
Closed 8 years ago.
I'm creating a table in MySql and I came across columns with datatype as mediumint followed by a number in parenthesis. What does this number denote?
https://dev.mysql.com/doc/refman/5.7/en/integer-types.html says that unsigned mediumint can take a max value of 16777215, so how does it differ if have columns with different sizes mediumint(6) or mediumint(10) ?
I suppose here in an answer:
http://dev.mysql.com/doc/refman/5.6/en/numeric-type-attributes.html
so difference is only in formatting output, nothing else...
This question already has answers here:
What's the PostgreSQL datatype equivalent to MySQL AUTO INCREMENT?
(11 answers)
Auto increment table column
(4 answers)
Closed 9 years ago.
In mySQL i am able to do
INSERT INTO table_name (column_name1, column_name2) VALUES('John', 'Doe);
As you can see I do not have to mention the ID, how would I do this in postgreSQL.
Thank you
Approach #1:
You can declare your ID column as Serial
In this case it will create an implicit sequence for your column.
Example :
CREATE TABLE MyTable
(
ID serial NOT NULL,
column1 type,
column2 type
}
Approach #2:
Or you can manually define a sequence and then assign its next value as Default value for the column.
CREATE SEQUENCE my_sequence START 1;
CREATE TABLE MyTable
(
ID integer DEFAULT nextval('my_sequence'::regclass) NOT NULL,
column1 type,
column2 type
}
This is not because of mysql that happens. You can make such this kind of query because you have set id as an auto_increment column
You can actually do the same thing in postgreSQL by using the serial pseudo data type instead
Example of primary column serial
id serial PRIMARY KEY,