Incorrect Oracle create table generation if a table includes Guid
See original GitHub issueCreateTable<T> generates invalid CREATE TABLE statement if a table has a Guid column without an explicit DB type when Oracle provider is being used.
[Table("Calculation")]
public class Calculation
{
/// <summary>The Id</summary>
[Column, Identity, PrimaryKey, NotNull]
public int Id { get; set; }
/// <summary>Client request id</summary>
[Column, NotNull]
public Guid RequestId { get; set; }
}
Resulting sql:
CREATE TABLE pfe.Calculation
(
Id Int NOT NULL,
RequestId Guid NOT NULL,
Status Int NOT NULL,
PathCount Int NOT NULL,
StartDate timestamp NOT NULL,
TimeHorizon Float NOT NULL,
FactorListId Int NOT NULL,
Created timestamp NOT NULL,
Updated timestamp NOT NULL,
CONSTRAINT PK_Calculation PRIMARY KEY (Id)
)
Oracle does not have the Guid column type. It should be raw(16). An addition of DataType = DataType.Binary, Length = 16 to the column attribute does not help also. After it the generated column type is Binary(16) which is also invalid. The only obvious way to workaround the problem is to set DbType=“Raw(16)” property of the Column attribute.
Environment details
linq2db version: 1.8.2
Database Server: Oracle 11g
Database Provider: Oracle.Managed
Operating system: Windows 7
Framework version: .NET Framework 4.6.2
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Creating a Table
Purpose. Use the CREATE TABLE statement to create one of the following types of tables: A relational table, which is the basic structure...
Read more >How to Use Create Table, Alter Table, and Drop Table in ...
An introduction to the create table, alter table, and drop table commands in Oracle Database. Use these to create, change, and remove ...
Read more >Specifying Partitioning When Creating Tables and Indexes
Oracle Database Object-Relational Developer's Guide for information specific to creating tables with object types, nested tables, or VARRAYs.
Read more >ORA-00900: invalid SQL statement
Cause: The datatype entered in the CREATE or ALTER TABLE statement is not valid. Action: Correct the syntax. Cause: A table or cluster...
Read more >Alter Table
Purpose. Use the ALTER TABLE statement to alter the definition of a nonpartitioned table, a partitioned table, a table partition, or a table...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
May be better to keep it and add proper default mappings later.
About second issue this should help: