Any commands for creating database using oracle command? as well as creating tables?

I have this in creating table but did not work. Having invalid table name error.

Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types

Public Class dump
    Dim conn As New OracleConnection
    Private cmd As OracleCommand
    Private da As OracleDataAdapter
    Private cb As OracleCommandBuilder
    Private ds As DataSet
    Dim lubid As String = "User Id= PETHOTEL" & ";Password= 911" & ";Data Source = xe"
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Try

   
        conn.ConnectionString = lubid
        conn.Open()
            Dim sql = "CREATE TABLE  'TRANS'" _
      & "(	'TRANS_ID' NUMBER NOT NULL ENABLE," _
         & " 'CAMOUNT' NUMBER NOT NULL ENABLE," _
          & "'COST' NUMBER NOT NULL ENABLE, " _
          & " 'CHANGE' NUMBER NOT NULL ENABLE," _
          & " 'CUSTOM_ID' NUMBER NOT NULL ENABLE, " _
          & "'EMP_ID' NUMBER, " _
          & "'PET_ID' NUMBER, " _
          & " 'DATESTART' DATE, " _
         & "'DATEEND' DATE," _
         & "  'SERVICES' VARCHAR2(100), " _
         & " 'STATUS' NUMBER, " _
         & "'ROOMCOST' NUMBER, " _
         & " 'DATETODAY' DATE, " _
         & " Constraint() 'TRANS_PK' PRIMARY KEY ('TRANS_ID') DISABLE" _
      & ") ;ALTER TABLE  'TRANS' ADD CONSTRAINT 'TRANS_FK' FOREIGN KEY ('CUSTOM_ID')" _
        & "REFERENCES()  'CUSTOMER' ('CUSTOM_ID') DISABLE;"

        cmd = New OracleCommand(sql, conn)
        cmd.ExecuteNonQuery()
        MessageBox.Show("Record updated", "Autobots Ex", MessageBoxButtons.OK, MessageBoxIcon.Information)
        conn.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
            conn.Close()
        End Try
    End Sub
End Class

First suggestion is remove all of the single quotes. They are only used for string field values in queries. I have MS SQ, not Oracle so I can't comment on the rest. Try the quotes and see how that works.

Creating database at run time does not make any sense.

You need to use EXECUTE IMMEDIATE to create tables at run time.

The largest database app I ever wrote was required to automatically create a new database on the first of every month. It looked to me like the OP was just trying to create a table, not a database.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.