P
P
pvgdrk2014-07-10 22:26:21
MySQL
pvgdrk, 2014-07-10 22:26:21

How to set default value for longtext field in MySql?

In the beginning it is necessary to explain that MySQL5 is either impossible to do by default in windows - a bug, or something else is not clear.
On the Internet it is written like this:
sql_mode='MYSQL40' or sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" so write in my.ini (in the [mysql] section as I understand it)
Neither works. When I try to set a default value, I get an error BLOB/TEXT column 'somecolumn' can't have a default value
And I need default values ​​when creating a record. You can transfer everything to the script - if the field is empty when reading, then write something to it. But it somehow turns out stupidly - to make a piece of code that will work exactly 1 time - at the first reading of the record. It is necessary that when creating a record, the fields are brought to standard values.
Forgot to say - Django is everything.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kis92, 2014-07-11
@pvgdrk

I don't know about Junga but the mysql doc says:
BLOB and TEXT columns can be indexed in MySQL version 3.23.2 and newer. Older versions of MySQL do not support indexing these columns.
BLOB and TEXT columns do not remove trailing characters, as is done for VARCHAR columns.
Try, when creating a record in the database, insert the desired value into this field.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question