I am creating a database it keeps on giving me error:
CREATE TABLE `pgdavplacments`.`drive` ( `drive_id` INT(5) NOT NULL AUTO_INCREMENT ,
`drive_name` VARCHAR(200) NOT NULL ,
`drive_date` DATE NOT NULL ,
`drive_time` TIME NOT NULL ,
`drive_info` VARCHAR(8000) NOT NULL ,
`eligibility1` INT(5) NOT NULL ,
`eligibility2` INT(5) NOT NULL ,
`eligibility3` INT(5) NOT NULL ,
PRIMARY KEY (`drive_id`(1000)))
ENGINE = InnoDB;
What is the problem here?
CREATE TABLE `pgdavplacments`.`drive` (
`drive_id` INT(5) NOT NULL AUTO_INCREMENT,
`drive_name` VARCHAR(200) NOT NULL,
`drive_date` DATE NOT NULL,
`drive_time` TIME NOT NULL,
`drive_info` VARCHAR(8000) NOT NULL,
`eligibility1` INT(5) NOT NULL,
`eligibility2` INT(5) NOT NULL,
`eligibility3` INT(5) NOT NULL,
PRIMARY KEY (`drive_id` )
) ENGINE=INNODB;
You can try above query.
Related
SQL sorgusu:
CREATE TABLE online(
idonline İNT( 10 ) UNSİGNED NOT NULL AUTO_INCREMENT ,
ip VARCHAR( 16 ) ,
domain VARCHAR( 100 ) ,
FKiduyeler İNT( 10 ) UNSİGNED,
lasttime TİMESTAMP DEFAULT 'CURRENT_TIMESTAMP',
PRIMARY KEY ( idonline ) ,
KEY online_index3587( ip ) ,
KEY online_index3588( domain ) ,
KEY online_index3592( FKiduyeler ) ,
KEY online_index3604( lasttime )
);
MySQL çıktısı: Belgeler
#1067 - Invalid default value for 'lasttime'
Before everthing sorry about my english; when l upload my db ,l got this proglem.Please help me.Thanks
CURRENT_TIMESTAMP instead of 'CURRENT_TIMESTAMP'
I instead of İ at multiple places.
CREATE TABLE `online`(
idonline INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
ip VARCHAR( 16 ) ,
domain VARCHAR( 100 ) ,
FKiduyeler INT( 10 ) UNSIGNED,
lasttime TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- lose the single quotes here
PRIMARY KEY ( idonline ) ,
KEY online_index3587( ip ) ,
KEY online_index3588( domain ) ,
KEY online_index3592( FKiduyeler ) ,
KEY online_index3604( lasttime )
);
Thank for helping, but when l do that I'm getting this problem:
CREATE TABLE visitor_chats ( visitor_id varchar(32) NOT NULL,
browser_id varchar(32) NOT NULL, visit_id varchar(32) NOT NULL,
chat_id int(11) unsigned NOT NULL, fullname varchar(255) NOT NULL,
email varchar(255) NOT NULL, company varchar(255) NOT NULL, status
tinyint(1) unsigned NOT NULL, typing tinyint(1) unsigned NOT NULL,
waiting tinyint(1) unsigned NOT NULL, area_code varchar(255) NOT NULL,
first_active int(10) unsigned NOT NULL, last_active int(10) unsigned
NOT NULL, qpenalty int(10) unsigned NOT NULL, request_operator
varchar(32) NOT NULL, request_group varchar(32) NOT NULL, question
varchar(255) NOT NULL, customs text NOT NULL, allocated int(11)
unsigned NOT NULL, internal_active tinyint(1) unsigned NOT NULL,
internal_closed tinyint(1) unsigned NOT NULL, internal_declined
tinyint(1) unsigned NOT NULL, external_active tinyint(1) unsigned NOT
NULL, external_close tinyint(1) unsigned NOT NULL, exit int(11) [...]
MySQL error
"#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 'exit int(11) unsigned NOT NULL,PRIMARY KEY
(visitor_id,browser_id,visit_id,c' at line 26"
CREATE TABLE `bank`.`Customer_registrationTable`
( `Account_no` INT NOT NULL ,
`Name` VARCHAR(100) NOT NULL ,
`Address` INT(100) NOT NULL ,
`Account_type` VARCHAR(100) NOT NULL ,
`Gender` VARCHAR(50) NOT NULL ,
`DOB` VARCHAR(100) NOT NULL ,
`Password` VARCHAR(100) NOT NULL ,
`Date` VARCHAR(100) NOT NULL ,
`Age` INT(10) NOT NULL ,
`Previous_Balance` DOUBLE(20) NOT NULL,
PRIMARY KEY (`Account_no`(30))) ENGINE = InnoDB;
after writing this I got problem that said,
#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 ') NOT NULL, PRIMARY KEY (`Account_no`(30))) WHERE ENGINE = InnoDB' at line 1
CREATE TABLE `bank`.`Customer_registrationTable`
( `Account_no` INT NOT NULL ,
`Name` VARCHAR(100) NOT NULL ,
`Address` INT(100) NOT NULL ,
`Account_type` VARCHAR(100) NOT NULL ,
`Gender` VARCHAR(50) NOT NULL ,
`DOB` VARCHAR(100) NOT NULL ,
`Password` VARCHAR(100) NOT NULL ,
`Date` VARCHAR(100) NOT NULL ,
`Age` INT(10) NOT NULL ,
`Previous_Balance` DOUBLE NOT NULL,
PRIMARY KEY (`Account_no`)) ENGINE = InnoDB;
PRIMARY KEY (Account_no) should not have (20)
Previous_Balance DOUBLE NOT NULL should not have (20), it should like DOUBLE(20, 2)
CREATE TABLE IF NOT EXISTS `customer_registrationtable` (
`Account_no` int(11) NOT NULL,
`Name` varchar(100) NOT NULL,
`Address` int(100) NOT NULL,
`Account_type` varchar(100) NOT NULL,
`Gender` varchar(50) NOT NULL,
`DOB` datetime NOT NULL,
`Password` varchar(100) NOT NULL,
`Date` datetime NOT NULL,
`Age` int(10) NOT NULL,
`Previous_Balance` double(20,2) NOT NULL,
PRIMARY KEY (`Account_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I have a problem when I run this SQL query:
CREATE TABLE `softwaredb`.`profile`
( `id` INT(11) NOT NULL AUTO_INCREMENT ,
`user_id` INT(11) NOT NULL ,
`gender` VARCHAR(255) NOT NULL ,
`height` INT(4) NOT NULL ,
`weight` INT(4) NOT NULL ,
`bodytype` INT(1) NOT NULL )
The error I keep running into is the following:
Incorrect table definition;
there can be only one auto column and it must be defined as a key
Try this
CREATE TABLE `softwaredb`.`profile`
( `id` INT(11) NOT NULL AUTO_INCREMENT ,
`user_id` INT(11) NOT NULL ,
`gender` VARCHAR(255) NOT NULL ,
`height` INT(4) NOT NULL ,
`weight` INT(4) NOT NULL ,
`bodytype` INT(1) NOT NULL ,
primary key (id) //specify id as primary key will sort out the error..try
)
OR Try
CREATE TABLE `softwaredb`.`profile`
( `id` INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT ,
`user_id` INT(11) NOT NULL ,
`gender` VARCHAR(255) NOT NULL ,
`height` INT(4) NOT NULL ,
`weight` INT(4) NOT NULL ,
`bodytype` INT(1) NOT NULL
)
I have prblem with sql when i try to check if table extist.
Am making component for joomla and when make install.sql i have sql syntax error.
check this and tell me what i do wrong:
DROP TABLE IF EXIST `#__ik_property_item`;
DROP TABLE IF EXIST `#__ik_property_categories`;
DROP TABLE IF EXIST `#__ik_property_type`;
DROP TABLE IF EXIST `#__ik_property_price_type`;
DROP TABLE IF EXIST `#__ik_property_agnts`;
DROP TABLE IF EXIST `#__ik_property_companies`;
DROP TABLE IF EXIST `#__ik_property_agnts`;
CREATE TABLE `#__ik_property_item` (
`id` INT NOT NULL AUTO_INCREMENT ,
`category_id` INT NULL ,
`property_type_id` INT NULL ,
`price_type_id` INT NULL ,
`company_id` INT NOT NULL ,
`agent_id` INT NOT NULL ,
`title` VARCHAR(45) NULL ,
`street` VARCHAR(45) NULL ,
`status` INT NULL ,
`featured` INT NULL ,
`yt_video` TEXT NULL ,
`map_lattitude` INT NULL ,
`map_longitude` VARCHAR(45) NULL ,
`beds` INT NULL ,
`baths` VARCHAR(45) NULL ,
`garage` VARCHAR(45) NULL ,
`flat_size` VARCHAR(45) NULL ,
`kitchens` VARCHAR(45) NULL ,
`year_build` VARCHAR(45) NULL ,
`floor` VARCHAR(45) NULL ,
`price` INT NULL ,
`image_1` VARCHAR(45) NULL ,
`image_2` VARCHAR(45) NULL ,
`image_3` VARCHAR(45) NULL ,
`image_4` VARCHAR(45) NULL ,
`image_5` VARCHAR(45) NULL ,
`meta_title` VARCHAR(45) NULL ,
`meta_description` TEXT NULL ,
`intro_text` TEXT NULL ,
`full_text` TEXT NULL ,
PRIMARY KEY (`id`) );
CREATE TABLE `#__ik_property_categories` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(45) NULL ,
PRIMARY KEY (`id`) );
CREATE TABLE `#__ik_property_type` (
`id` INT NOT NULL AUTO_INCREMENT ,
`title` VARCHAR(45) NULL ,
PRIMARY KEY (`id`) );
CREATE TABLE `#__ik_property_price_type` (
`id` INT NOT NULL AUTO_INCREMENT ,
`title` VARCHAR(45) NULL ,
PRIMARY KEY (`id`) );
CREATE TABLE `#__ik_property_agnts` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(45) NULL ,
`last_name` VARCHAR(45) NULL ,
`first_name` VARCHAR(45) NULL ,
`email` VARCHAR(45) NULL ,
`website` VARCHAR(45) NULL ,
`phone` VARCHAR(45) NULL ,
`company` VARCHAR(45) NULL ,
PRIMARY KEY (`id`) );
CREATE TABLE `#__ik_property_companies` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(45) NULL ,
`logo` VARCHAR(45) NULL ,
`email` VARCHAR(45) NULL ,
`phone` VARCHAR(45) NULL ,
`website` VARCHAR(45) NULL ,
`street` VARCHAR(45) NULL ,
`fax` VARCHAR(45) NULL ,
`intro_text` VARCHAR(45) NULL ,
`full_text` VARCHAR(45) NULL ,
`image_1` VARCHAR(45) NULL ,
`image_2` VARCHAR(45) NULL ,
`image_3` VARCHAR(45) NULL ,
PRIMARY KEY (`id`) );
When i remove
DROP TABLE IF EXIST `#__ik_property_item`;
DROP TABLE IF EXIST `#__ik_property_categories`;
DROP TABLE IF EXIST `#__ik_property_type`;
DROP TABLE IF EXIST `#__ik_property_price_type`;
DROP TABLE IF EXIST `#__ik_property_agnts`;
DROP TABLE IF EXIST `#__ik_property_companies`;
DROP TABLE IF EXIST `#__ik_property_agnts`;
All is success executed and when i call uninstall.sql code inside is like above all work good. But i need to check on installation if that tables exist if exist i must delete and save new.
Thanks
I am using MySQL to create a small database. and facing some issues in foreign keys and primary key. I really don't understand as it seems a simple problem.
CREATE TABLE IF NOT EXISTS `db_trimms`.`urban_area` (
`area_id` INT(10) NOT NULL ,
`city` VARCHAR(60) NOT NULL ,
`state` VARCHAR(60) NOT NULL ,
`urban_area` VARCHAR(60) NOT NULL ,
`census_region` VARCHAR(60) NOT NULL ,
`area_no` VARCHAR(60) NOT NULL ,
`freeway_speed` VARCHAR(60) NOT NULL ,
`arterial_speed` VARCHAR(60) NOT NULL ,
PRIMARY KEY (`area_id`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
its running successfully. But while create another table and creating foreign key referring to the area_id of the above table...its creating issues...
#1005 - Can't create table 'db_trimms.emiss_others_offpeak' (errno: 150) (Details...)
and here is the query
CREATE TABLE IF NOT EXISTS `db_trimms`.`emiss_others_offpeak` (
`area_id` INT(10) UNSIGNED NOT NULL ,
`ammonia` VARCHAR(60) NOT NULL ,
`atm_carbon_dio` VARCHAR(60) NOT NULL ,
`carbon_dio_equiv` VARCHAR(60) NOT NULL ,
`carbon_mono` VARCHAR(60) NOT NULL ,
`methane` VARCHAR(60) NOT NULL ,
`nitrogen_dio` VARCHAR(60) NOT NULL ,
`nitrogen_oxide` VARCHAR(60) NOT NULL ,
`nitrous_oxide` VARCHAR(60) NOT NULL ,
`non_meth_hydrocarbs` VARCHAR(60) NOT NULL ,
`oxides_of_nitrogen` VARCHAR(60) NOT NULL ,
`particulate_matter_pm10` VARCHAR(60) NOT NULL ,
`particulate_matter_pm2_5` VARCHAR(60) NOT NULL ,
`sulfate` VARCHAR(60) NOT NULL ,
` sulfur_dioxide` VARCHAR(60) NOT NULL ,
`total_hydrocarbon` VARCHAR(60) NOT NULL ,
`vol_org_comp` VARCHAR(60) NOT NULL ,
PRIMARY KEY (`area_id`) ,
CONSTRAINT `fk_others_offpeak_urban`
FOREIGN KEY (`area_id` )
REFERENCES `db_trimms`.`urban_area` (`area_id` )
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
The data types are incompatible with each other. Make column area_id from table urban_area also UNSIGNED.
`area_id` INT(10) UNSIGNED NOT NULL ,
SQLFiddle Demo