I'm using my Web Application in Godaddy Hosting Server. Php Version is 7.1 and mysql Version is 5.6
while i'm trying
ALTER TABLE aos_products_quotes
modify COLUMN discount varchar(255) DEFAULT 'Percentage' NULL ,
modify COLUMN parent_type varchar(255) NULL ,
modify COLUMN parent_id char(255) NULL ;
these query in my domain sql server its shows
MYSQL #1071 Error Specified Key value is too long
I think i need to use mysql 5.7 or else need to set the global prefix variable is 1..But the Global setting need super privileges..At Godaddy side they told its impossible on Shared hosting..
I try my best about that issue so anyone guide me to solve that issue..
Thanks in advance...
There are many options to fix this:
You can try by changing the character set of columns so that they
use less bytes in storage.
You can change / remove indexing of the table. May be you are using
composite index whose limit is reached after this alteration.
Try less length of varchar() columns.
share the complete table structure to help you better.
Thanks
Related
On azure I created a new MySQL Database instance. In this db I create a table using this script:
CREATE TABLE ROLES(
ID INTEGER PRIMARY KEY AUTO_INCREMENT,
ROLE_NAME VARCHAR(30) NOT NULL
);
Then I insert values using this script:
INSERT INTO `beezzy`.`roles` (`ROLE_NAME`) VALUES ('admin');
INSERT INTO `beezzy`.`roles` (`ROLE_NAME`) VALUES ('owner');
INSERT INTO `beezzy`.`roles` (`ROLE_NAME`) VALUES ('consultant');
after execution table contains such rows:
Why DB generates IDs like '11' and '21'?
I run the same script on my local machine and everything works fine. IDs was '1', '2', '3'
Please run the following query.
SELECT ##auto_increment_increment
If the value is more than 1 then set it to 1 by the following query:
SET ##auto_increment_increment=1;
Note: This change is visible for the current connection only.
EDIT:
In order to set it globally so that other connections can also see the change you need to set it for global and session too.
SET ##GLOBAL.auto_increment_increment = 1;
SET ##SESSION.auto_increment_increment = 1;
So other connections can see this change now.
More:
This value will be reset if you restart your MySQL server. In order to make this change permanent you need to write this variable under [mysqld] secion in your my.cnf [for linux] or my.ini [for windows] file.
[mysqld]
auto-increment-increment = 1
Your autoincrement is probably 10, however this is probably by design. Azure uses ClearDB which uses an autoincrement of 10 with a reason: namely replication.
When I use auto_increment keys (or sequences) in my database, they
increment by 10 with varying offsets. Why?
ClearDB uses circular replication to provide master-master MySQL
support. As such, certain things such as auto_increment keys (or
sequences) must be configured in order for one master not to use the
same key as the other, in all cases. We do this by configuring MySQL
to skip certain keys, and by enforcing MySQL to use a specific offset
for each key used. The reason why we use a value of 10 instead of 2 is
for future development.
You should not change the autoincrement value.
cleardb faq
We ran a script the other day using laravel 4 schema that added a column (service_id) to all tables where the table name starts with ids_
When we run the script, we made a mistake in not setting a default value for the column that we added.
I believe that there must be someway that either via laravel 4 schema or a bash script that should allow us to rollback and add the default value but I can't seam to figure it out.
Can someone please help.
Thanks.
Try this:
ALTER TABLE `your_table` CHANGE COLUMN `service_id` `service_id` VARCHAR(10) NOT NULL DEFAULT 'your_default_value';
where VARCHAR(10) is an example, but must remain the same as you specified before.
Table rows I inserted in database I created are unresponsive to clicks to change their values or delete rows:
SELECT * FROM Database.Table WHERE ;
DELETE FROM TABLE WHERE LIMIT 1;
Of course I have an error in My SQL syntax; There's no need to check the manual that corresponds to my MariaDB server version for the right syntax to use near '' at line 1, since I know reference (id=someNumber) is needed, But I thougt it should be added automatically. Should I configure something else in adittion to what I've already configured? All my Tables have their primary and unique keys.
Issue only happens with my tables in my database. System databases bring their rows for editing or even deleting them when I click their edit and delete links. Writing commands in consoles is no problem (textbox is marking invalid syntax for valid syntax, but commands still run).
Since tools provided with currently X.A.M.P.P. most recent version (5.6.14) are outdated (P.H.P. 5.6.14) and messy with some tools included (P.H.P.MyAdmin 4.4.14, MariaDB 10.0.17). I updated them (5.6.15, 4.5.2, 10.1.19) by just downloading, replacing and rewriting their .ini's with the options usually mandatory and obviously demanding.
Tried new database with a single table of the ones I have: Here is the export:
CREATE TABLE Categoria(
id bigint(20) NOT NULL,
orden bigint(20) NOT NULL,
activa tinyint(4) DEFAULT 1,
nombre varchar(256) NOT NULL,
detalle varchar(512) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY nombre (nombre),
UNIQUE KEY orden (orden)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO Categoria (id,orden,activa,nombre,detalle) VALUES
(1, 1, 1, 'COBRE', 'Rradiadores, estañados y otros.'),
(2, 2, 1, 'BRONCE', 'rebaba, radiadores etc.. Se incluye al antimonio'),
(3, 3, 1, 'ALUMINIO', 'Rebaba, rines, perfiles, cables, botes, radiadores, litografías, aleaciones, etc.');
Problem persists. Maybe adding two unique keys confuses phpmyadmin.
I'm using Adminer in the meanwhile. It doesn't come with autocomplete in command, but everything else is just better.
Fresh Reinstall and similar does not help...That includes trying online demo, seing no problem and state indirectly tha I'm crazy.
So, if you know I missed something, please let me know...
There is a problem with database tables in MariaDB version 10.0.17.
There are some new and stable versions available.
Download MariaDB version 10.0.21 which is a stable version and the errors have been fixed.
As Marc said,the demo package of xampp uses MariaDB version 10.0.21 and therefore it shows no errors.
Please download the lates version from here:
https://downloads.mariadb.org/mariadb/10.0.21/
Please accept the answer if you are satisfied to remove this from the unanswered section.
WHERE must have an expression after it. It is up to you, not phpmyadmin, to provide something. Or remove "WHERE".
DELETE ... LIMIT 1 should have an ORDER BY, else which "1" will it delete??
I have a CSV I download from the State of Florida so I'm not in control over what's in the file. There are some fields (such as price) that are sometimes null. In my table where I'm importing these values, I marked sold_price as BIGINT, Unsigned, Allow Null and default of Null. However, when I attempt to insert a NULL value (empty cell in the CSV), I get the error:
[PDOException]
SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'sold_price' at row 1
I followed the advice in this answer someone posted and that fixes the problem. However, whenever MySQL is restarted, I get the error again and have to redo that query.
Also, I don't think that's the appropriate way to fix the problem, is it? What should I be doing in cases where a field such as sold_price is null and I'm trying to insert it into a table?
I'm running MySQL version 5.6.13.
you can disable the strict mode. In you my.ini-file you'll find something like
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Change that to:
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
I have two tables with bigint:
table1
id bigint(20) PK autoincrement
name varchar(40),
text
table2
id bigint(20) PK autoincrement
created datetime
text_field
id_table1_ref bigint(20)
After inserting data into table1 and trying to insert table1.id into table2.id_table1_ref,
the number is different, i.e.:
Number 1552545662588 from table1.t1 becomes 1552545662, or even worse, a negative number.
I know this is an issue with settings, but I can't figure out how to manage this.
I tried to set up signed/unasigned values for the fields, but it doesn't work.
This is happening on my UNIX local computer, on the server all is working ok, at least for now.
Any help would be much appreciated.
You need to CONVERT it to a string in SQL before getting it into PHP. In PHP, you can use GMP to handle the number.
MySQL docs on converting: http://dev.mysql.com/doc/refman/5.7/en/cast-functions.html#function_convert
It's also the case that PHP under at least some 64-bit operating systems (eg FreeBSD AMD64) uses an 8-byte int, verifiable by testing with
echo 'Size of int is '.PHP_INT_SIZE ;
So if you're only going to be running a 64-bit operating system, you shouldn't need to manage the BIGINTs as strings in PHP.
I solved this problem by change to another php version,that is changing from 64bit php version to 32bit php version. That really works for me.