When I try to exeecute the folliwng in SQL, I get error, I am trying to add multiple columns with same value to one table.
CREATE TABLE IF NOT EXISTS `vendor` (
`product_id` varchar(255) NOT NULL
), `Vendor_SKU_or_Stock_Number` varchar(255) NOT NULL
), `Brand_Name` varchar(255) NOT NULL
), `Image_URL5`varchar(255) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ERROR: #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 ' Vendor_SKU_or_Stock_Number varchar(255) NOT NULL
), Brand_Name varchar(255)' at line 13
Please help
You have too many closing parenthesis, and your table name and field names should not be quoted.
Try this:
CREATE TABLE IF NOT EXISTS vendor (
product_id varchar(255) NOT NULL
, Vendor_SKU_or_Stock_Number varchar(255) NOT NULL
, Brand_Name varchar(255) NOT NULL
, Image_URL5 varchar(255) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Removed ")"
CREATE TABLE IF NOT EXISTS `vendor` (
`product_id` varchar(255) NOT NULL
, `Vendor_SKU_or_Stock_Number` varchar(255) NOT NULL
, `Brand_Name` varchar(255) NOT NULL
, `Image_URL5`varchar(255) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Try this
CREATE TABLE IF NOT EXISTS `vendor` (
`product_id` varchar(255) NOT NULL
, `Vendor_SKU_or_Stock_Number` varchar(255) NOT NULL
, `Brand_Name` varchar(255) NOT NULL
, `Image_URL5`varchar(255) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Try this
CREATE TABLE IF NOT EXISTS vendor (
product_id varchar(255) NOT NULL,
vendor_SKU_or_Stock_Number varchar(255) NOT NULL,
brand_Name varchar(255) NOT NULL,
image_URL5 varchar(255) NOT NULL) ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
Related
Hello i am still learning and i faced this problem,please how can i fix it ?
A symbol name was expected! (near "id" ) At least one column
definition was expected. (near "id" ) Unexpected beginning of
statement. (near "11" ) Unrecognized statement type. (NOT NULL)
CREATE TABLE "categories" (
"id" int(11) NOT NULL,
"name" varchar (255) NOT NULL
) "ENGINE" = INNODB DEFAULT CHARSET = lantin1;
CREATE TABLE "stages"
( "id" int (11) NOT NULL,
"categorie_id" int(11) NOT NULL,
"entreprise" varchar(255) NOT NULL,
"nome" varchar(255) NOT NULL,
"description" varchar(255) NOT NULL,
"location" varchar(255) NOT NULL,
"contact" varchar(255) NOT NULL,
"contact_email" varchar(255) NOT NULL
) ENGINE = INNODB DEFAULT CHARSET = latin1;
ALTER TABLE "categories"
ADD PRIMARY KEY ("id");
ALTER TABLE "stages"
ADD PRIMARY KEY ("id");
ALTER TABLE "categories"
MODIFY "id" int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE "stages"
MODIFY "id" int(11) NOT NULL AUTO_INCREMENT;
how can i fix it's showing a lot of errors,i am still learning please help me
You should remove all " characters like below:
CREATE TABLE categories (
id int(11) NOT NULL,
name varchar (255) NOT NULL
) ENGINE = INNODB DEFAULT CHARSET = lantin1;
CREATE TABLE stages
( id int (11) NOT NULL,
categorie_id int(11) NOT NULL,
entreprise varchar(255) NOT NULL,
nome varchar(255) NOT NULL,
description varchar(255) NOT NULL,
location varchar(255) NOT NULL,
contact varchar(255) NOT NULL,
contact_email varchar(255) NOT NULL
) ENGINE = INNODB DEFAULT CHARSET = latin1;
ALTER TABLE categories
ADD PRIMARY KEY (id);
ALTER TABLE stages
ADD PRIMARY KEY (id);
ALTER TABLE categories
MODIFY id int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE stages
MODIFY id int(11) NOT NULL AUTO_INCREMENT;
I was following a youtube tutorial here. Even though I followed it to a t. The problem being is it didn't work because I have an updated version. I hope you can help. The SQL preview is here:
CREATE TABLE `test_database`.`members`
(
`id` INT NOT NULL AUTO_INCREMENT ,
`username` VARCHAR(255) NOT NULL ,
`country` VARCHAR(255) NOT NULL ,
`county/state` VARCHAR(255) NOT NULL ,
`city` VARCHAR(255) NOT NULL ,
`bio` TEXT NOT NULL ,
`email` VARCHAR(255) NOT NULL ,
`password` VARCHAR(255) NOT NULL ,
`signupdate` DATETIME NOT NULL ,
`lastlogin` DATETIME NOT NULL ,
`accounttype` ENUM(0) NOT NULL ,
`emailactivated` ENUM(0) NOT NULL DEFAULT '\'0\'' ,
PRIMARY KEY (`id`), UNIQUE (`email`)
)
ENGINE = MyISAM;
This was the error message I received: #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
'0) NOT NULL , `emailactivated` ENUM(0) NOT NULL DEFAULT '\'0\'' , PRIMARY KE
at line 1
Try to change your query like this:
CREATE TABLE test_database.members
(
id INT NOT NULL AUTO_INCREMENT ,
username VARCHAR(255) NOT NULL ,
country_state VARCHAR(255) NOT NULL ,
country VARCHAR(255) NOT NULL ,
city VARCHAR(255) NOT NULL ,
bio TEXT NOT NULL ,
email VARCHAR(255) NOT NULL ,
password VARCHAR(255) NOT NULL ,
signupdate DATETIME NOT NULL ,
lastlogin DATETIME NOT NULL ,
accounttype ENUM('0') NOT NULL ,
emailactivated ENUM('0') NOT NULL DEFAULT '0' ,
PRIMARY KEY (id), UNIQUE (email)
)
ENGINE = MyISAM;
try to use _ instead of/for column name. or just use camel case. Sometimes if you use /. It will give you an error.
for enum column type, it just like you give a choice, so better give the choice after that. like ENUM('a', 'b', 'c') NOT NULL DEFAULT 'a'
Instead. What Version of MySQL did you use? And Also for phpMyAdmin ?. Sometimes there is also a bug.
Read link
you cant set enum(0) that what wrong
check this if you want use enum
I am getting this error on import of a ~1g SQL dump:
[ERROR in query 620] Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
I would like to look at this query, but there are 4537 of them (at least by count of the semicolons) so how do I find the 620th of them quickly? I opened the sql file in xcode, but I am open to grepping if that is the solution.
Per Steven’s request I am generalizing this more. Say we have an sql file of form:
# Dump of table table1
# ------------------------------------------------------------
DROP TABLE IF EXISTS `table1`;
CREATE TABLE `table1` (
`a` int(11) NOT NULL AUTO_INCREMENT,
`b` varchar(255) NOT NULL DEFAULT '',
`c` varchar(255) NOT NULL DEFAULT '',
`d` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`a`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table table2
# ------------------------------------------------------------
DROP TABLE IF EXISTS `table2`;
CREATE TABLE `table2` (
`a` int(11) NOT NULL AUTO_INCREMENT,
`b` varchar(255) NOT NULL DEFAULT '',
`c` varchar(255) NOT NULL DEFAULT '',
`d` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`a`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
...
# Dump of table table310
# ------------------------------------------------------------
DROP TABLE IF EXISTS `table310`;
CREATE TABLE `table310` (
`a` int(11) NOT NULL AUTO_INCREMENT,
`b` varchar(255) NOT NULL DEFAULT '',
`c` varchar(255) NOT NULL DEFAULT '',
`d` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`a`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
# Dump of table table311
# ------------------------------------------------------------
DROP TABLE IF EXISTS `table311`;
CREATE TABLE `table311` (
`a` int(11) NOT NULL AUTO_INCREMENT,
`b` varchar(255) NOT NULL DEFAULT '',
`c` varchar(255) NOT NULL DEFAULT '',
`d` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`a`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
So in this example (... represents intervening tables) the query that starts with CREATE TABLE table310 would be the 620th Query if everything followed this pattern. Say the pattern and naming convention was not so regular, how would I be able to go to the 620th query referenced in the Error?
#!/usr/bin/awk -f
BEGIN {
RS = ORS = ";"
}
NR == 6
Result
CREATE TABLE `table310` (
`a` int(11) NOT NULL AUTO_INCREMENT,
`b` varchar(255) NOT NULL DEFAULT '',
`c` varchar(255) NOT NULL DEFAULT '',
`d` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`a`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I've a project at school and i must use a Derby DB.
I'm using eclipse and the SQL Scrapbook to execute my SQL script.
Here is the problem:
My SQL script was generated by Mysql Workbench, we did a schemas and then exported it to a .sql
When i try to execute it in the SQL Scrapbook, I have MANY errors, the sql seems not to be adapted to derby (for example, AUTOINCREMENT is now (START WITH 1, INCREMENT BY 1).
Here is my .sql :
SET #OLD_UNIQUE_CHECKS=##UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET #OLD_FOREIGN_KEY_CHECKS=##FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET #OLD_SQL_MODE=##SQL_MODE, SQL_MODE='TRADITIONAL';
DROP SCHEMA IF EXISTS `mydb` ;
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `mydb` ;
-- -----------------------------------------------------
-- Table `mydb`.`User`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`User` ;
CREATE TABLE IF NOT EXISTS `mydb`.`User` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(45) NOT NULL ,
`lastname` VARCHAR(45) NOT NULL ,
`email` VARCHAR(45) NOT NULL ,
`adress` VARCHAR(45) NOT NULL ,
`city` VARCHAR(45) NOT NULL ,
`zip` VARCHAR(45) NOT NULL ,
`login` VARCHAR(45) NOT NULL ,
`password` VARCHAR(45) NOT NULL ,
`admin` TINYINT(1) NOT NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;
-- -----------------------------------------------------
-- Table `mydb`.`Movie`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Movie` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Movie` (
`id` INT NOT NULL AUTO_INCREMENT ,
`title` VARCHAR(45) NOT NULL ,
`resume` VARCHAR(500) NULL ,
`genre` VARCHAR(60) NULL ,
`grade` INT(11) NULL ,
`review_pub` VARCHAR(200) NULL ,
`review_gen` VARCHAR(200) NULL ,
`poster` VARCHAR(100) NULL ,
`duration` INT(11) NULL ,
`release_date` VARCHAR(45) NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Projection`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Projection` ;
CREATE TABLE IF NOT EXISTS `mydb`.`Projection` (
`id` INT NOT NULL AUTO_INCREMENT COMMENT ' ' ,
`date` DATE NULL ,
`length` INT(11) NULL ,
`Movie_id` INT NOT NULL ,
`price` DECIMAL(10,0) NULL ,
`location` VARCHAR(45) NOT NULL ,
`place_nbr` INT(11) NOT NULL ,
PRIMARY KEY (`id`) ,
INDEX `fk_Projection_Movie` (`Movie_id` ASC) ,
CONSTRAINT `fk_Projection_Movie`
FOREIGN KEY (`Movie_id` )
REFERENCES `mydb`.`Movie` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`command`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`command` ;
CREATE TABLE IF NOT EXISTS `mydb`.`command` (
`id` INT NOT NULL AUTO_INCREMENT ,
`Projection_id` INT NOT NULL ,
`User_id` INT NOT NULL ,
`paid` TINYINT(1) NOT NULL ,
PRIMARY KEY (`id`) ,
INDEX `fk_command_Projection1` (`Projection_id` ASC) ,
INDEX `fk_command_User1` (`User_id` ASC) ,
CONSTRAINT `fk_command_Projection1`
FOREIGN KEY (`Projection_id` )
REFERENCES `mydb`.`Projection` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_command_User1`
FOREIGN KEY (`User_id` )
REFERENCES `mydb`.`User` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=#OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=#OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=#OLD_UNIQUE_CHECKS;
Thank you
Try using DdlUtils (http://db.apache.org/ddlutils/) to export your schema from your MySQL database, then you can import that same schema to Derby.
I have a table called users:
CREATE TABLE `users` (
`UID` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`username` VARCHAR(45) NOT NULL ,
`password` VARCHAR(200) NOT NULL ,
`name` VARCHAR(45) NOT NULL ,
`email` VARCHAR(255) NOT NULL ,
`phone` VARCHAR(30) NOT NULL ,
`logo` VARCHAR(255) NULL ,
`address` VARCHAR(100) NULL ,
`information` TEXT NULL ,
`announcement` TEXT NULL ,
`role` INT UNSIGNED NULL ,
`yahoo` VARCHAR(100) NULL ,
`twitter` VARCHAR(20) NULL ,
`timelogin` DATETIME NULL,
PRIMARY KEY (`UID`) ,
UNIQUE INDEX `UID_UNIQUE` (`UID` ASC) ,
UNIQUE INDEX `name_UNIQUE` (`name` ASC) ,
UNIQUE INDEX `logo_UNIQUE` (`logo` ASC) ,
UNIQUE INDEX `username_UNIQUE` (`username` ASC))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;
the problem is that I want to add or insert a new row like
`image_seal` VARCHAR(255) NULL ,
after logo, can we do something like that in mysql ? append-thing?
Thanks
Adam Ramadhan
ALTER TABLE users ADD COLUMN image_seal VARCHAR(255) NULL AFTER logo;
Check here for Syntax of ALTER TABLE
It seems you want to add a new column to your table, not a row.
From the MySQL reference it seems you can use the keyword AFTER.
ALTER TABLE users ADD COLUMN image_seal VARCHAR(255) AFTER logo;
should do the trick.
What are you using to administer your database? SQLBuddy, PHPmyAdmin and others can do this for you, without you needing to run queries.