CREATE TABLE dbo.PhotoLibrary (
PhotoLibraryID INT IDENTITY (1, 1) PRIMARY KEY,
ImageName VARCHAR(100),
Photo VARBINARY(MAX)
)
While using the above code in SQL I am getting the error help me
You are passing in SQL Server code to Oracle. Big problem.
CREATE TABLE PhotoLibrary (
PhotoLibraryID INT PRIMARY KEY,
ImageName VARCHAR2(100),
Photo VARBINARY(MAX)
);
Oracle doesn't understand identity. If you want an auto-incrementing column, then you need to use a sequence. Here is an example.
Related
hey guys i am new to databricks and i have been trying to create tables using spark sql but i was unable to do so due to the error : Error in SQL statement: ParseException:
no viable alternative at input 'Create table offices(\n\tAreaCode VARCHAR(10) NOT NULL PRIMARY'(line 2, pos 31)
As i do not know what is wrong with the code as i am able to create the exact table using the below code. Do let me know if there is any suggestion or alternatives!.
Create table offices(
AreaCode VARCHAR(10) NOT NULL PRIMARY KEY,
city VARCHAR(50) NOT NULL
)
Take the primary key out
Create table offices(
AreaCode VARCHAR(10) NOT NULL,
city VARCHAR(50) NOT NULL
)
I am creating a table to house my XML data that is coming in to my SQL Server database. Below is my code for my Create Table statement. My issue is I want to create a primary key that is a combination of two columns (SpecNum and IssueNum). A record should look like this (50125-001). However I am having issue with type mismatches and it will not allow my to declare it as xml. Does anyone know how to correct this? Please see code below and thank you in advance.
CREATE TABLE ImportXML (
SpecNum xml,
IssueNum xml,
SpecStatus xml,
ID as (SpecNum + '-' + IssueNum) NOT NULL PRIMARY KEY
);
50125-001 isn't XML, it's a varchar. I suspect what you want is:
CREATE TABLE dbo.ImportXML (SpecNum int NOT NULL,
IssueNum int NOT NULL,
SpecStatus xml,
ID AS (CONVERT(varchar(10), SpecNum) + '-' + CONVERT(varchar(10), IssueNum))
PERSISTED NOT NULL PRIMARY KEY); --You should really define the name of the PK CONSTRAINT too
I am trying to create table having different indexes with single query but H2 gives Error for example:
create table tbl_Cust
(
id int primary key auto_increment not null,
fid int,
c_name varchar(50),
INDEX (fid)
);
but this gives error as
Unknown data type: "("; SQL statement:
[Error Code: 50004]
[SQL State: HY004]
Due to this I have to run 2 different queries to create table with Index. First query to create table and then second query to add index with
create INDEX c_fid on tbl_Cust(fid);
Is there something wrong in my query or H2 simply does not support this creation of table with index in single query?
Interesting question. The solution is even more interesting, as it involves MySQL compatibility mode.
It's actually possible to perform the exact same command you wrote without any modification, provided you just add to your jdbc url the MySQL mode.
Example URL like this: jdbc:h2:mem:;mode=mysql
SQL remains:
create table tbl_Cust
(
id int primary key auto_increment not null,
fid int,
c_name varchar(50),
INDEX (fid)
);
Update count: 0
(15 ms)
Too bad I did not see this question earlier... Hopefully the solution might become handy one day to someone :-)
I could resolve the problem. According to
http://www.h2database.com/html/grammar.html#create_index
I modified the query. It works fine with my H2 server.
CREATE TABLE subscription_validator (
application_id int(11) NOT NULL,
api_id int(11) NOT NULL,
validator_id int(11) NOT NULL,
PRIMARY KEY (application_id,api_id),
CONSTRAINT subscription_validator_ibfk_1 FOREIGN KEY (validator_id) REFERENCES validator (id) ON UPDATE CASCADE
);
CREATE INDEX validator_id ON subscription_validator(validator_id);
This is driving me insane, can anyone help me understand why the following statements all return the following error?
create table JMS_PENDING_MESSAGE (id number primary key, queuex nvarchar2(200), messagex nclob(1000));
create table JMS_PENDING_MESSAGE (id number primary key, queuex nvarchar2(200), messagex nclob(10000));
create table JMS_PENDING_MESSAGE (id integer primary key, queuex nvarchar2(200), messagex nclob(10000));
And the error message:
ORA-00907: missing right parenthesis
Im running over JDBC using ojdbc5.jar if it makes a difference! Any help much appreciated, Im going insane
A CLOB is a CLOB (and, as o.k.w. points out, a NCLOB is an NCLOB). You don't need to give it a size:
create table JMS_PENDING_MESSAGE
(id integer primary key, queuex nvarchar2(200), messagex nclob);
CREATE TABLE PERMISSIONS(
ID BIGINT NOT NULL PRIMARY KEY,
NAME VARCHAR(255) NOT NULL, UNIQUE(ID)
)
CREATE TABLE ROLES(
ID BIGINT NOT NULL PRIMARY KEY,
NAME VARCHAR(255)
)
I want to run this in MySql. When I try to execute separately each create-query everything works fine but they don't work together. I thought that separator was missed and tried to put semicolon after each query but MySql says that I have syntax mistake near ";" . Where is the mistake?
using the queries in the mysql console with a semi-colon after the each statement works. maybe you use an api (like php's mysql_query) which only supports one query at the time.
It's a semi-colon.
What is the equivalent of 'go' in MySQL?
I don't have a MySql instance running here and it's by no means my cup of tea but I believe you're supposed to separate your queries with ;.
CREATE TABLE PERMISSIONS(
ID BIGINT NOT NULL PRIMARY KEY,
NAME VARCHAR(255) NOT NULL, UNIQUE(ID)
) ;
CREATE TABLE ROLES(
ID BIGINT NOT NULL PRIMARY KEY,
NAME VARCHAR(255)
)