Error 1064 sql phpmyadmin - sql

This is my sql query:
CREATE TABLE estados (
id int IDENTITY(1,1) PRIMARY KEY,
nombre VARCHAR(20) NOT NULL,
paridad int NOT NULL
);
and it keeps telling me:
#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 '(1,1) PRIMARY KEY,
nombre VARCHAR(20) NOT NULL,
paridad int NOT NULL
I don't know why is this, I am using 10.1.10-MariaDB. I don't know why I have syntax error, and if this has to do with the versions.

IDENTITY is for SQL Server. You should use AUTO_INCREMENT instead:
CREATE TABLE estados (
id int AUTO_INCREMENT PRIMARY KEY,
nombre VARCHAR(20) NOT NULL,
paridad int NOT NULL
);

Related

Error 1064 from trying to forward engineer an ERD

I'm still learning SQL at the moment and i keep getting this error when i try to forward engineer my tables. Could really use some assistance on figuring out what's causing the error.
Executing SQL script in server
ERROR: 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 'VISIBLE,
CONSTRAINT fk_Player_Team1
FOREIGN KEY (team_id)
REFERENC' at line 11
SQL Code:
CREATE TABLE IF NOT EXISTS `sts18`.`Player` (
`player_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`team_id` INT UNSIGNED NOT NULL,
`player_lname` VARCHAR(45) NOT NULL,
`player_fname` VARCHAR(45) NOT NULL,
`player_age` TINYINT UNSIGNED NOT NULL,
`player_phone` BIGINT UNSIGNED NOT NULL,
`player_email` VARCHAR(100) NULL,
`player_notes` VARCHAR(255) NULL,
PRIMARY KEY (`player_id`),
INDEX `fk_Player_Team1_idx` (`team_id` ASC) VISIBLE,
CONSTRAINT `fk_Player_Team1`
FOREIGN KEY (`team_id`)
REFERENCES `sts18`.`Team` (`team_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
SQL script execution finished: statements: 17 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch

oracle auto increment missing right parenthesis

create table grocery_types(
type_id int auto_increment primary key,
grocery_type varchar(50) not null,
remarks varchar(30)
);
I am using oracle sql developer IDE for sql queries, i am executing this query in my IDE but its giving an error that "missing right parenthesis", and in IDE there is a red line under the auto_increment keyword, please tell me whats wrong in the code, thanks.
I think there isn't a way to use auto_increment if yours is 11g.
But you can use a sequence :
create table grocery_types(
type_id int primary key,
grocery_type varchar(50) not null,
remarks varchar(30)
);
CREATE SEQUENCE type_id_seq START WITH 1;

Error 1064(42000) Creating a Table in msql5

CREATE TABLE Message(
MessageID int unsigned not null auto_increment primary key,
naiveUserID int unsigned(7) NOT NULL,
Title varchar(20),
bodyOfText TEXT(2000)
);
I keep trying to run this simple create table blurb on a Mysql5 database and I keep getting the error:
ERROR 1064 (42000): 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 '(7) NOT NULL,
Title varchar(20),
bodyOfText TEXT(2000)
)' at line 3
I've googled the proper syntax from several different sites and can't make anything run! The maddening part is that when I use my teacher's code, which is very similar to this apart from some data types, it runs perfectly:
CREATE TABLE EMPL (
Eid int unsigned not null auto_increment primary key,
Name varchar(20),
title varchar(30),
salary int,
emailsuffix varchar(60)
);
It's because your syntax is indeed wrong: there's no int unsigned(7)type; try this:
CREATE TABLE Message(
MessageID int unsigned not null auto_increment primary key,
naiveUserID int(7) unsigned NOT NULL,
Title varchar(20),
bodyOfText TEXT(2000)
);
or:
CREATE TABLE Message(
MessageID int unsigned not null auto_increment primary key,
naiveUserID int unsigned NOT NULL,
Title varchar(20),
bodyOfText TEXT(2000)
);

Error with auto_increment while conneted to Postgres via psql and puTTY

I'm getting this error in puTTY. Not sure why, looks right to me ...
psql:pierre.sql:10: ERROR: syntax error at or near "AUTO_INCREMENT"
LINE 2: c_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
^
psql:pierre.sql:18: ERROR: syntax error at or near "AUTO_INCREMENT"
LINE 2: r_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
--DROP TABLE customer, reservation;
CREATE TABLE customer(
c_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
c_ref VARCHAR(30) NOT NULL,
f_name VARCHAR(30) NOT NULL,
l_name VARCHAR(30) NOT NULL,
address VARCHAR(100) NOT NULL,
email VARCHAR(100) NOT NULL,
phone VARCHAR(11) NOT NULL
);
CREATE TABLE reservation(
r_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
c_id VARCHAR(30) NOT NULL REFERENCES customer(c_id),
book_date DATE NOT NULL CHECK (book_date <= now()),
s_time DOUBLE NOT NULL,
e_time DOUBLE NOT NULL,
amount INTEGER NOT NULL
);
Any ideas why?
auto_increment looks like something you'd use with MySQL.
But, here, it seems you are using PostgreSQL.
According to the datatype serial section of the manual, postgresql's equivalent of auto_increment is serial or bigserial.
Quoting that page :
The data types serial and bigserial are not true types, but merely
a notational convenience for setting up unique identifier columns
(similar to the AUTO_INCREMENT property supported by some other databases).
In Postgres 10 or later consider an IDENTITY column:
CREATE TABLE customer(
c_id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
...
(PRIMARY KEY also makes it NOT NULL automatically.)
Details:
Auto increment table column
In Postgres 9.6 or older consider a serial like Pascal already suggested.
Works in pg 10 or later, too, but IDENTITY is generally superior.

Error in my SQLite syntax

New to SQLite so I don't know what I'm doing wrong. I'm just getting an error saying:
SQLSTATE[HY000]: General error: 1 near "CREATE": syntax error
Here's my SQL:
CREATE TABLE users (
id INTEGER NOT NULL PRIMARY KEY,
date_created DATETIME NOT NULL,
date_updated DATETIME NOT NULL,
username VARCHAR(32) NOT NULL,
password VARCHAR(32) NOT NULL,
role VARCHAR(32) NOT NULL DEFAULT 'member',
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
email VARCHAR(128) NOT NULL
)
CREATE TABLE subscribers (
id INTEGER NOT NULL PRIMARY KEY,
name VARCHAR(40) DEFAULT NULL,
email VARCHAR(255) NOT NULL UNIQUE
)
CREATE TABLE weekly_download (
id INTEGER NOT NULL PRIMARY KEY,
filename TEXT NOT NULL,
download_date DATE NOT NULL,
body TEXT
)
put a semicolon after each statement.
CREATE TABLE ( ... ) ;
CREATE TABLE ( ... ) ;
Start with simple statements using the sqlite3 CLI.
Then, if you forget a ;, you will get quick feedback and can build up to more complex SQL.
$ sqlite3 /tmp/test.db
SQLite version 3.5.9
Enter ".help" for instructions
sqlite> create table badsyntax;
SQL error: near ";": syntax error
sqlite> create table abc (x,y);
sqlite>
Don't forget semi-colons!