I did this simple SQL Query succesfuly from PHP Admin 4 years ago with SQL 5.1. Now I try the same in SQL 5.5 for my new project and getting a syntax error. Mayby somebody can help me to get in the game again.Thanks
SQL query:
CREATE TABLE `mfl` (
`id` INT NOT NULL,
`rank` MEDIUMINT NOT NULL ,
PRIMARY KEY ( `id` )
) TYPE = MYISAM
MySQL said: Documentation
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
near 'TYPE = MYISAM' at line 5
Try using
Engine=MyISAM
as Type is deprecated.
Related
I am creating an openfire database in mysql but whenvever i try to create it, it shows 'The Openfire database schema does not appear to be installed. Follow the installation guide to fix this error.'.
Log
2018.12.01 14:40:48 org.jivesoftware.database.SchemaManager - SchemaManager: Failed to execute SQL:
CREATE TABLE ofRosterGroups ( rosterID BIGINT NOT NULL, rank TINYINT NOT NULL, groupName VARCHAR(255) NULL, PRIMARY KEY (rosterID, rank), INDEX ofRosterGroup_rosterid_idx (rosterID) );
2018.12.01 14:40:48 org.jivesoftware.database.SchemaManager - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rank TINYINT NOT NULL, groupName VARCHAR(' at line 1
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rank TINYINT NOT NULL, groupName VARCHAR(' at line 1
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:781)
at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:666)
at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
This error comes up everytime while creating the openfire db tables
Any help will be appreciated
Thanks in advance
'rank' is, as of MySQL 8.0.2, a reserved keyword, which causes this query to fail. A fix for this issue has been provided in version 4.3.0 of Openfire.
I have an old database. Am uploading it into SQL using phpmyadmin But when I want to import it I get an error. It seems the first table even cannot get imported:
CREATE TABLE `manager` (
`username` VARCHAR(20) NOT NULL,
`password` VARCHAR(50) NOT NULL,
`email` VARCHAR(100) NOT NULL ,
`deposit` VARCHAR( 50 ) DEFAULT '0' NOT NULL
)
TYPE = MYISAM
CHARACTER SET utf8 COLLATE utf8_new_ci
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use
near 'TYPE = MYISAM CHARACTER SET utf8 COLLATE utf8_new_ci' at line 7
How can I resolve this issue?
ENGINE=MyISAM is what you should be using I believe. Also, its probably a good idea to encapsulate your field names like this :
`username` and `password` just to prevent mysql/mariadb picking them up as reserved words.
TYPE is not a valid table_option in Mysql 8, see Manual at https://dev.mysql.com/doc/refman/8.0/en/create-table.html. There is a list of all valid table_options beginning in line 110.
I have an old database
Maybe you can give us more information about your used database by runing the mysql command
SELECT VERSION();
write a sql sentence to create a table in MySQL
CREATE TABLE fb_web_user_feeds(id bigint not null primary key auto_increment,host_id bigint,,author varchar(64),time varchar(64),user_feed text)
BUT IT ERRORS:
pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'author varchar(64),time varchar(64),user_feed text)' at line 1")
could you please tell me the reason
It's because you have 2 commas here:
host_id bigint,,author varchar(64)
It should just be 1 comma making your syntax be:
CREATE TABLE fb_web_user_feeds(id bigint not null primary key auto_increment,host_id bigint,author varchar(64),time varchar(64),user_feed text)
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your
MariaDB server version for the right syntax to use near ') VIRTUAL,
`title_type` VARCHAR(45) NULL DEFAULT null,
PRIMARY KEY (`id`))' at line 2
Here is a part of script:
CREATE TABLE IF NOT EXISTS `sggis`.`maps_type` (
`id` INT GENERATED ALWAYS AS () VIRTUAL,
`title_type` VARCHAR(45) NULL DEFAULT 'yandex',
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SQL says that problem is in the 2nd line, but i can't find it.
Code generated by MySQL Workbench.
When using VIRTUAL columns you need to specify the expression
Any legal, deterministic expression which can be calculated is
permitted, with the following exceptions:
Your expression is blank.
IF COL_LENGTH('Characters', 'name') IS NULL
BEGIN
ALTER TABLE `Characters` ADD `name` INT(32) UNSIGNED NOT NULL;
END
I am trying to write some sql that will insert a column name into the table "Characters" if it is not already existant, however I am getting errors which I do not understand (quite new to SQL) and I could use some help understanding why it is not working. I have gotten the IF part from another Question, and the ALTER part from the DBMS I'm using, PhpMyAdmin 2.11.4.
It is using MySQL 5.6 apparently and this is the error:
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF COL_LENGTH('Characters', 'name') IS NULL
BEGIN
ALTER TABLE `Characters` AD' at line 1