Can we create TABLE datatype in Sybase? - sybase-ase

As we have in SQL Server, is it possible to create a TABLE datatype in Sybase? I checked a couple of online forums but was not able to find any answer.

TABLE is a T-SQL reserved word, so is not usable as the name of a datatype.
The full list of reserved words can be found in the Sybase ASE Quick Reference Guide

I had a similar question recently. The table data type does exist in T-SQL as illustrated by MSDN library HOWEVER, It is NOT SUPPPORTED in Sybase. In T-SQL the table data type can be declared AS
DECLARE #tableVariable table(Column1 int, Column2 int)
I had intended on using the table variable to store a result set for use later to be UNION'd for each value in an array, but I was disappointed to find out that Sybase ASE DOES NOT support the table data type variable. A list of supported data types can be found here

To create a temporary table in Sybase you will use the code:
CREATE TABLE #table (Column1 int, Column2 int)
Example of select:
SELECT * FROM #table
The table exists until the current session or procedure ends, or until its owner drops it using drop table.


IS TABLE OF and AS TABLE OF when creating PL/SQL nested table collection types

I am curious about syntax usage with PL/SQL collection type creations. What is the difference between is table of and as table of when creating a PL/SQL nested table collection type, if any? I've seen only is table of in the Oracle help documentation but code I've come across uses both is table of and as table of when creating the collection type. I tried both and both statements appear to execute at the same speed and hold data as intended.
For example, for object type
create or replace type new_emp_ot is object
ssn number(9),
lname varchar2(200),
fname varchar2(200)
is there any discernible difference between how Oracle processes
create or replace type new_emp_nt as table of new_emp_ot;
create or replace type new_emp_nt is table of new_emp_ot;
IS and AS are interchangeable in the CREATE TYPE syntax, there is no difference in this case.
Although the syntax diagram is incorrect... it makes it look like IS/AS are optional, but you can't actually omit them.

BigQuery create Table differences between standard and legacy sql

I have a few questions around the create table syntax in standard and legacy sql
The new BigQueryUI doesn't show standard sql types and shows only legacy types. I understand they are mapped one to one with the legacy types but the examples in creating partitioned tables shows options which are not available in the UI
If I create a table using the JSON field schema can I still use the standard sql?
The BigQueryUI shows only partitioning the table by Ingestion time, but I want to create a table with date column and I don't see an option for it. If I have to create the DDL manually, I did not see the examples on how to use JSON field schema to construct a create table statement.
The new BigQueryUI doesn't show standard sql types
BigQuery standardSQL and LegacySQL are 2 options to write SQL syntax (See this link for more detail) and have nothing to do with the column Types in BigQuery, Details on table types can be found in this link, I also find this Link helpful
If I create a table using the JSON field schema can I still use the standard sql?
To create a table using JSON you need to run bq command line, If you need help how to write this syntax let us know
but I want to create a table with date column and I don't see an option for it
You can use this standardSQL syntax to do this:
CREATE OR REPLACE TABLE `project.dataset.tableId`
CLUSTER BY cluster_col AS
SELECT * from sourceTable
Note: myDate column is a column in the source table

How to change a column type of a BigQuery table by querying and exporting to itself?

I have a integer type column in my BigQuery table and now I need to convert it to a float column. I also have to keep all records. What I want to do is changing the column type. Not casting.
I've read that it's possible to do it just by exporting results of a query on a table to itself.
How to do it?
Using SELECT with writing result back to table
CAST(int_field AS FLOAT) AS float_field,
FROM YourTable
This approach will co$t you scan of whole table
To execute this - you should use Show Option button in BQ Web UI and properly set options as in below example. After you run this - your table will have that column with float vs. original integer data type as you wanted. Note: You should use proper/same field name for both int_field and float_field
if you would just needed to add new column I would point you to Tables: patch GBQ API.
I am not sure if this API allows to change type of column - I doubt - but it is easy to check
Using Jobs: insert EXTRACT and then LOAD
Here you can extract table to GCS and then load it back to GBQ with adjusted schema
Above approach will a) eliminate cost cost of querying (scan) tables and b) can help with limitations that you can come up if you have complex schame (with records/repeated/nested, etc. type /mode)

Can SqlBulkCopy create a table from a Sql selection

Can SqlBulkCopy create a table, kind of like a SELECT INTO?
I think answer above wasn't quite clear.
You must create table with SQL. There is no other way. And if you need just to create column structure, then it is quite simple if your source is in the same server, it is enough to do this:
Select * from source_table into destination_table where 1=2
If your source is not in same server (e.g. it is excel or dbf file or whatever), the easiest thing to do is to connect to it with ODBC (or SQL if possible), and send him:
Select * from source_table where 1=2
and then collect result into DataTable. Then in second step you should create stored procedure on your destination server that will take that table as argument and then insert it into new table.
A bit more precisely, try this for SQL procedure:,339028455,339282577,00.htm
And create SqlCommnand object in c# and add to its Parameters collection SqlParameter that is SqlDbType.Structured
I didn't go into every single detail, but hope that it can help.
It seems that SqlBulkCopy can not create tables by itself. The destination table has to be predefined. In the case where the destination has got an auto incremental identity (int), just use a 1 in the select statement i.e.
SQL Server will handle the auto increment by itself.

Adding columns to a sybase table with unique auto_identity index option

I've inherited a Sybase database that has the 'unique auto_identity index' option enabled on it. As part of an upgrade process I need to add a few extra columns to the tables in this database i.e.
alter table mytable add <newcol> float default -1 not null
When I try to do this I get the follow error:
Column names in each table must be unique, column name SYB_IDENTITY_COL in table #syb__altab....... is specifed more than once
Is it possible to add columns to a table with this property enabled?
Update 1:
I created the following test that replicates the problem:
use master
sp_dboption 'esmdb', 'unique auto_identity indexoption',true
use esmdb
create table test_unique_ids (test_col char)
alter table test_unique_ids add new_col float default -1 not null
The alter table command here produces the error. (Have tried this on ASE 15/Solaris and 15.5/Windows)
Update 2:
This is a bug in the Sybase dbisql interface, which the client tools Sybase Central and Interactive SQL use to access the database and it only appears to affect tables with the 'unique auto_identity index' option enabled.
To work around the problem use a different SQL client (via JDBC for example) to connect to the database or use isql on the command line.
Should be no problem to ALTER TABLE with such columns; the err msg indicates the problem regards something else. I need to see the CREATE TABLE DDL.
Even if we can't ALTER TABLE, which we will try first, there are several work-arounds.
Hah! Internal Sybase error. Open a TechSupport case.
Make sure you get jthe the exact DDL. sp_help . Note the IDENTITY columns and indices.
Create a staging table, exactly the same. Use the DDL from (1). Exclude the Indices.
INSERT new_table SELECT old_table. If the table is large, break it into batches of 1000 rows per batch.
Now create the Indices.
If the table is very large, AND time is an issue, then use bcp. You need to research that first, I am happy to answer questions afterwards.
When I ran your sample code I first get the error:
The 'select into' database option is not enabled for database 'mydb'. ALTER TABLE with data copy cannot be done. Set the 'select into' database option and re-run
This is no doubt because the data within your table needs copying out because the new column is not null. This will use tempdb I think, and the error message you've posted refers to a temp table. Is it possible that this dboption has been accidentally enabled for the tempdb?
It's a bit of a shot in the dark, as I only have 12.5 to test on here, and it works for me. Or it could be a bug.