I want to import the "Countries of the World" database of opengeocode.org into a MySQL database to extend it by postal addressing format information. Is there a database scheme public available?
http://opengeocode.org/download/cow.php
It's a great database of information, would be great if they had it in MySQL format.
Anyway just in case anyone else comes across this page, here's what I did to import the data. I didn't spend hours on this, so might need some tweaking but should get you well on the way. You might need to tweak the number of header lines if they change the comments in the future.
DROP TABLE IF EXISTS countries_of_the_world ;
CREATE TABLE IF NOT EXISTS countries_of_the_world (
id INT NOT NULL AUTO_INCREMENT,
ISO3166a2 CHAR(2) NOT NULL ,
ISO3166a3 CHAR(3) NULL ,
ISO3166n3 INT(3) NULL ,
FIPS104 CHAR(2) NULL ,
ISOen_name VARCHAR(255) NOT NULL ,
ISOen_proper VARCHAR(255) NOT NULL ,
ISOen_ro_name VARCHAR(255) NULL ,
ISOen_ro_proper VARCHAR(255) NULL ,
ISOfr_name VARCHAR(255) NULL ,
ISOfr_proper VARCHAR(255) NULL ,
ISOes_name VARCHAR(255) NULL ,
UNGEGNen_name VARCHAR(255) NULL ,
UNGEGNen_longname VARCHAR(255) NULL ,
UNGEGNfr_name VARCHAR(255) NULL ,
UNGEGNfr_longname VARCHAR(255) NULL ,
UNGEGNes_name VARCHAR(255) NULL ,
UNGEGNes_longname VARCHAR(255) NULL ,
UNGEGNru_name VARCHAR(255) NULL ,
UNGEGNru_longname VARCHAR(255) NULL ,
UNGEGNlc_ro_name VARCHAR(255) NULL ,
UNGEGNlc_ro_longname VARCHAR(255) NULL ,
BGN_name VARCHAR(255) NULL ,
BGN_proper VARCHAR(255) NULL ,
BGN_longname VARCHAR(255) NULL ,
BGNlc_longname VARCHAR(255) NULL ,
BGNlc_name VARCHAR(255) NULL ,
PCGN_name VARCHAR(255) NULL ,
PCGN_proper VARCHAR(255) NULL ,
PCGN_longname VARCHAR(255) NULL ,
FAOit_name VARCHAR(255) NULL ,
FAOit_proper VARCHAR(255) NULL ,
FAOit_longname VARCHAR(255) NULL ,
EKI_name VARCHAR(255) NULL ,
EKI_longname VARCHAR(255) NULL ,
conabbr VARCHAR(45) NULL ,
HasCapital TINYINT NULL ,
BGN_capital VARCHAR(255) NULL ,
UNGEGNlc_capital VARCHAR(255) NULL ,
UNen_capital VARCHAR(255) NULL ,
UNfr_capital VARCHAR(255) NULL ,
UNes_capital VARCHAR(255) NULL ,
UNru_capital VARCHAR(255) NULL ,
EKI_capital VARCHAR(255) NULL ,
BGNc_latitude DOUBLE NULL ,
BGNc_longitude DOUBLE NULL ,
UNc_latitude DOUBLE NULL ,
UNc_longitude DOUBLE NULL ,
continent CHAR(2) NULL ,
subcontinent CHAR(2) NULL ,
ISOregion SMALLINT NULL ,
ISOsubregion SMALLINT NULL ,
language VARCHAR(45) NULL ,
population INT NULL ,
year SMALLINT NULL ,
BGN_demonym VARCHAR(255) NULL ,
BGN_demonym_adj VARCHAR(255) NULL ,
ITU SMALLINT NULL ,
IVC VARCHAR(3) NULL ,
land INT NULL ,
water INT NULL ,
land_total INT NULL ,
latitude DOUBLE NULL ,
longitude DOUBLE NULL ,
maxlatitude DOUBLE NULL ,
minlatitude DOUBLE NULL ,
minlongitude DOUBLE NULL ,
maxlongitude DOUBLE NULL ,
url_gov VARCHAR(255) NULL ,
url_stats VARCHAR(255) NULL ,
url_gis VARCHAR(255) NULL ,
url_post VARCHAR(255) NULL ,
PRIMARY KEY (id) )
ENGINE = InnoDB DEFAULT CHARSET=utf8;
LOAD DATA INFILE '/tmp/cow.txt'
INTO TABLE countries_of_the_world
FIELDS TERMINATED BY '; ' LINES TERMINATED BY '\r\n' IGNORE 29 LINES
(
ISO3166a2,
ISO3166a3,
ISO3166n3,
FIPS104,
ISOen_name,
ISOen_proper,
ISOen_ro_name,
ISOen_ro_proper,
ISOfr_name,
ISOfr_proper,
ISOes_name,
UNGEGNen_name,
UNGEGNen_longname,
UNGEGNfr_name,
UNGEGNfr_longname,
UNGEGNes_name,
UNGEGNes_longname,
UNGEGNru_name,
UNGEGNru_longname,
UNGEGNlc_ro_name,
UNGEGNlc_ro_longname,
BGN_name,
BGN_proper,
BGN_longname,
BGNlc_longname,
BGNlc_name,
PCGN_name,
PCGN_proper,
PCGN_longname,
FAOit_name,
FAOit_proper,
FAOit_longname,
EKI_name,
EKI_longname,
conabbr,
HasCapital,
BGN_capital,
UNGEGNlc_capital,
UNen_capital,
UNfr_capital,
UNes_capital,
UNru_capital,
EKI_capital,
BGNc_latitude,
BGNc_longitude,
UNc_latitude,
UNc_longitude,
continent,
subcontinent,
ISOregion,
ISOsubregion,
language,
population,
year,
BGN_demonym,
BGN_demonym_adj,
ITU,
IVC,
land,
water,
land_total,
latitude,
longitude,
maxlatitude,
minlatitude,
minlongitude,
maxlongitude,
url_gov,
url_stats,
url_gis,
url_post
);
Related
I'm using PHPMyAdmin, hosted with hostgator, to add a table to a database, but I keep getting the following 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 ') NOT NULL , note TEXT NOT NULL , cardNumber BIGINT(20) NOT NULL , `nameC' at line 1
Here's what I have:
and here's the preview of the SQL
CREATE TABLE `nightwin_mark-inn`.`guests` (
`id` INT(3) NOT NULL AUTO_INCREMENT ,
`dateIn` DATE NOT NULL ,
`dateOut` DATE NOT NULL ,
`email` TEXT NOT NULL ,
`phone` INT(10) NOT NULL ,
`room` TINYINT(2) NOT NULL ,
`price` DOUBLE(6) NOT NULL ,
`note` TEXT NOT NULL ,
`cardNumber` BIGINT(20) NOT NULL ,
`nameCard` TEXT NOT NULL ,
`expDate` TEXT NOT NULL ,
`cvc` TINYINT(3) NOT NULL ,
PRIMARY KEY (`id`)
)
What's causing this issue? Do I have the length of one of the fields wrong?
Try to use this
price` DOUBLE(6,2) NOT NULL //9999.99 max value stored
instead of
price` DOUBLE(6) NOT NULL
Note: for price field use datatype DECIMAL more preferable. In FLOAT or DOUBLE datatype you will get rounding number issue
Reference
You can try below - DOUBLE(6) should be only DOUBLE
CREATE TABLE `nightwin_mark-inn`.`guests` ( `id` INT(3) NOT NULL AUTO_INCREMENT ,
`dateIn` DATE NOT NULL , `dateOut` DATE NOT NULL , `email` TEXT NOT NULL ,
`phone` INT(10) NOT NULL , `room` TINYINT(2) NOT NULL , `price` DOUBLE NOT NULL ,
`note` TEXT NOT NULL , `cardNumber` BIGINT(20) NOT NULL , `nameCard` TEXT NOT NULL ,
`expDate` TEXT NOT NULL , `cvc` TINYINT(3) NOT NULL , PRIMARY KEY (`id`))
please try using this MySQL statement
CREATE TABLE `guests` ( `id` INT(3) NOT NULL AUTO_INCREMENT , `dateIn` DATE NOT NULL , `dateOut` DATE NOT NULL , `email` TEXT NOT NULL , `phone` INT(10) NOT NULL , `room` TINYINT(2) NOT NULL , `price` DOUBLE(6,2) NOT NULL , `note` TEXT NOT NULL , `cardNumber` BIGINT(20) NOT NULL , `nameCard` TEXT NOT NULL , `expDate` TEXT NOT NULL , `cvc` TINYINT(3) NOT NULL , PRIMARY KEY (`id`));
please try using this MySQL statement
CREATE TABLE guests ( id INT(3) NOT NULL AUTO_INCREMENT , dateIn DATE NOT NULL , dateOut DATE NOT NULL , email TEXT NOT NULL , phone INT(10) NOT NULL , room TINYINT(2) NOT NULL , price DOUBLE(6,2) NOT NULL , note TEXT NOT NULL , cardNumber BIGINT(20) NOT NULL , nameCard TEXT NOT NULL , expDate TEXT NOT NULL , cvc TINYINT(3) NOT NULL , PRIMARY KEY (id));
I am trying to create a table on my database. this is the 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 ') NOT NULL , `ctc` DOUBLE(5) NOT NULL , `ref` VARCHAR(50) NOT NULL , `date` D' at line 1
My query:
CREATE TABLE `job`.`form_details` (
`email_id` VARCHAR(50) NOT NULL ,
`name` VARCHAR(50) NOT NULL ,
`number` VARCHAR(14) NOT NULL ,
`city` VARCHAR(50) NOT NULL ,
`skill` VARCHAR(50) NOT NULL ,
`qualification` VARCHAR(50) NOT NULL ,
`position` VARCHAR(50) NOT NULL ,
`exp` DOUBLE(5) NOT NULL ,
`ctc` DOUBLE(5) NOT NULL ,
`ref` VARCHAR(50) NOT NULL ,
`date` DATE NOT NULL ,
`time stamp` TIMESTAMP(30) NOT NULL ) ENGINE = InnoDB;
A double's precision is specified by two arguments - (M, D) - M digits in total and D digits after the decimal point. A timestamp's precision must be no greater than 6. So:
CREATE TABLE `job`.`form_details` (
`email_id` VARCHAR(50) NOT NULL ,
`name` VARCHAR(50) NOT NULL ,
`number` VARCHAR(14) NOT NULL ,
`city` VARCHAR(50) NOT NULL ,
`skill` VARCHAR(50) NOT NULL ,
`qualification` VARCHAR(50) NOT NULL ,
`position` VARCHAR(50) NOT NULL ,
`exp` DOUBLE(5, 2) NOT NULL , -- Two arguments for the double's precision
`ctc` DOUBLE(5, 2) NOT NULL , -- Here too
`ref` VARCHAR(50) NOT NULL ,
`date` DATE NOT NULL ,
`time stamp` TIMESTAMP(6) NOT NULL -- Timestamp precision capped at 6
) ENGINE = InnoDB
DROP DATABASE IF EXISTS `Database` ;
CREATE DATABASE `Database` ;
DROP TABLE IF EXISTS `Registration Form` ;
CREATE TABLE `Registration Form`
(
`ID` int(11) NOT NULL AUTO_INCREMENT ,
`Username` varchar(50) NOT NULL ,
`Password` varchar(50) NOT NULL ,
`Display Name` varchar(255) NOT NULL ,
`Question` varchar(255) NOT NULL ,
`Answer` varchar(255) NOT NULL ,
`Title` varchar(10) NOT NULL ,
`Name` varchar(255) NOT NULL ,
`Date Of Birth` date NOT NULL ,
`Gender` varchar(10) NOT NULL ,
`Address` varchar(255) NOT NULL ,
`Postal Code` int(11) NOT NULL ,
`City / Town` varchar(255) NOT NULL ,
`Federal Territory / State` varchar(255) NOT NULL ,
`Citizenship` varchar(255) NOT NULL ,
`E-mail` varchar(255) NOT NULL ,
`Contact Number` int(20) NOT NULL ,
`Registration Date` datetime NOT NULL ,
PRIMARY KEY ( `ID` )
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
I'm just starting to work arounnd mysql and php ... so bear with me as im a newbie ...
What does ALL the code after the CREATE() mean ? Why is there a ENGINE and DEFAULT what do they do ? Is CHARSET same as collation , if yes why not put it inside the row instead ? Do you need to give a length/value for date and daetime ?
CREATE TABLE is the sql clause which is required to creating a table.
After that you have to give a table name i.e "Registration Form" .but avoid spaces in between table name
Next what ever you gave those are column name along with their datatype and size.NOT NULL means while inserting data those column can't be blank.
For more details check the below link
http://www.tutorialspoint.com/mysql/mysql-create-tables.htm
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 getting the below message on a table I am trying to create.
The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs
Anyone know the answer to this please?
-- Table `warrington_central`.`job`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `warrington_central`.`job` (
`id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT ,
`alias_title` VARCHAR(255) NOT NULL ,
`reference_number` VARCHAR(100) NOT NULL ,
`title` VARCHAR(255) NOT NULL ,
`primary_category` SMALLINT(5) UNSIGNED NOT NULL ,
`secondary_category` SMALLINT(5) UNSIGNED NOT NULL ,
`tertiary_category` SMALLINT(5) UNSIGNED NULL ,
`address_id` BIGINT(20) UNSIGNED NOT NULL ,
`geolocation_id` BIGINT(20) UNSIGNED NULL ,
`company` VARCHAR(255) NOT NULL ,
`description` VARCHAR(10000) NOT NULL ,
`skills_required` VARCHAR(10000) NOT NULL ,
`job_type` TINYINT(2) UNSIGNED NOT NULL ,
`experience_months_required` TINYINT(2) UNSIGNED NOT NULL ,
`experience_years_required` TINYINT(2) UNSIGNED NOT NULL ,
`salary_range` VARCHAR(30) NOT NULL ,
`extra_benefits_above_salary` VARCHAR(500) NOT NULL ,
`available_from` DATE NULL ,
`available_to` DATE NULL ,
`extra_location_details` VARCHAR(1000) NOT NULL ,
`contact_email` VARCHAR(100) NOT NULL ,
`contact_phone_number` VARCHAR(20) NOT NULL ,
`contact_mobile_number` VARCHAR(20) NOT NULL ,
`terms_conditions_application` VARCHAR(5000) NOT NULL ,
`link_to_profile` ENUM('0','1') NOT NULL ,
`created_on` DATETIME NOT NULL ,
`updated_on` DATETIME NOT NULL ,
`updated_by` BIGINT(20) UNSIGNED NOT NULL ,
`add_contact_form` ENUM('0','1') NOT NULL ,
`admin_package_id` TINYINT(1) UNSIGNED NOT NULL ,
`package_start_date` DATETIME NOT NULL ,
`package_end_date` DATETIME NULL ,
`package_comment` VARCHAR(500) NOT NULL ,
`viewable_to_members_only` ENUM('0','1') NOT NULL ,
`advertise_to` DATETIME NULL ,
`show_comment` ENUM('0','1') NOT NULL ,
`hits` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 ,
`visible` ENUM('0','1') NOT NULL DEFAULT '0' ,
`approved` ENUM('I/* large SQL query (3.9 KB), snipped at 2,000 characters */
/* SQL Error (1118): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs */
SHOW WARNINGS;
Change description and skills_required to be type text
You are getting that message because the sum of all the fields is > 65k