Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALTER TABLE issue on $db->query() #1035

Open
iamahmadahmadi opened this issue Feb 9, 2022 · 2 comments
Open

ALTER TABLE issue on $db->query() #1035

iamahmadahmadi opened this issue Feb 9, 2022 · 2 comments

Comments

@iamahmadahmadi
Copy link

Hey there,
I tried to change a column type from INT to VARCHAR and I used this command, but I got no result/error.
$db->query("ALTER TABLE tablename CHANGE balance balance VARCHAR(300) NOT NULL;");
Would you please help me out?
Thanks.

@catfan
Copy link
Owner

catfan commented Feb 11, 2022

Make sure your query is correct.

/* MySQL */
ALTER TABLE table_name RENAME COLUMN old_name TO new_name;
/* MariaDB */
ALTER TABLE table_name CHANGE COLUMN old_name TO new_name;

@catfan
Copy link
Owner

catfan commented Feb 11, 2022

The above answer is supported on MySQL 8.0.

Just make sure the database can execute the query successfully based on the version. Because query() is just executing the query alone for the database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants