> ERROR: syntax error at or near "BYTE"

Started by postgresdba111@outlook.comover 5 years ago3 messagesgeneral
Jump to latest
#1postgresdba111@outlook.com
postgresdba111@outlook.com

CREATE TABLE "A"
(
"b" DATE,
"c " NUMBER,
" d " VARCHAR2(255 BYTE),
"e " VARCHAR2(255 BYTE))

When ı create table then after error why error in byte please heplp me thanks

error:> ERROR: syntax error at or near "BYTE"

#2Magnus Hagander
magnus@hagander.net
In reply to: postgresdba111@outlook.com (#1)
Re: > ERROR: syntax error at or near "BYTE"

On Fri, Aug 21, 2020 at 10:33 AM postgresdba111@outlook.com <
postgresdba111@outlook.com> wrote:

CREATE TABLE "A"
(
"b" DATE,
"c " NUMBER,
" d " VARCHAR2(255 BYTE),
"e " VARCHAR2(255 BYTE))

When ı create table then after error why error in byte please heplp me
thanks

error:> ERROR: syntax error at or near "BYTE"

This is not valid syntax in PostgreSQL (or I believe, in SQL in general).
This is Oracle syntax.

PostgreSQL does not have the number data type, so you'll eventually get a
problem there as well. Which data type to use instead depends on what data
you are actually going to store.

PostgreSQL does not have the varchar2 data type (so you will have to use
varchar).

And finally, varchar just takes a number, not the special construct with
BYTE. PostgreSQL varchar:s always limit the size based on number of
characters, not bytes.

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/&gt;
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/&gt;

#3Paul Förster
paul.foerster@gmail.com
In reply to: postgresdba111@outlook.com (#1)
Re: > ERROR: syntax error at or near "BYTE"

Hi,

On 21. Aug, 2020, at 10:19, postgresdba111@outlook.com wrote:

CREATE TABLE "A"
(
"b" DATE,
"c " NUMBER,
" d " VARCHAR2(255 BYTE),
"e " VARCHAR2(255 BYTE))

When ı create table then after error why error in byte please heplp me thanks

error:> ERROR: syntax error at or near "BYTE"

several problems:

a) don't put blanks in your names, neither table names nor attributes.
b) PostgreSQL doesn't have NUMBER. Use integer instead.
c) PostgreSQL doesn't have VARCHAR2. User text instead.

So, the correct statement would be:

create table a (
b date,
c integer,
d text,
e text
);

Hope this helps.

Cheers,
Paul