Open Source RDBMS - Seamless, Scalable, Stable and Free

English | Login |Register


1
(click on this box to dismiss)

How do I SHOW CREATE TABLE in CUBRID?

MySQL provides SHOW CREATE TABLE syntax which shows the CREATE TABLE statement that creates the given table including all its CONSTRAINTS and INDEXes. How do I obtain the same information in CUBRID?

Edit: I need an SQL solution so that I can execute the query in scripting language such as PHP. So, CUBRID Manager solution is not exactly what I am looking for.

Considering that $object_name = 'stadium', the following will be the output.

CREATE TABLE stadium(
    code INTEGER NOT NULL,
    nation_code CHAR NOT NULL,
    name VARCHAR(50) NOT NULL,
    area NUMERIC,
    seats INTEGER,
    address VARCHAR(100),
    CONSTRAINT pk_stadium_code PRIMARY KEY (code)
);

Does anyone know pure PHP solution?

링크 댓글 쓰기 (0) 선택된 답변
질문시간 3년 전
eye
91
34 답변들
0

One solution would be in CUBRID Manager,

  1. by right clicking on a table,
  2. selecting the option Edit Table,
  3. and then the tab SQL Script.
The code appears such as for the "athlete" table from demodb.

CREATE TABLE "athlete"(
      "code" integer AUTO_INCREMENT(16693,1),
      "name" character varying(40) NOT NULL,
      "gender" character(1),
      "nation_code" character(3),
      "event" character varying(30),
      CONSTRAINT pk_athlete_code PRIMARY KEY("code")
);

링크 댓글 쓰기 (1)
답변시간 3년 전
dolph
35
0

Another way to SHOW CREATE TABLE statement in CM is:

  1. right click on the table;
  2. choose "Copy SQL to Editor"  ->  "CREATE <table>"
    or
    choose "Copy SQL to Clipboard"  ->  "CREATE <table>"
The first one will paste the statement directly in CM Query Editor, while the second will copy it to the buffer.

링크 댓글 쓰기 (0)
답변시간 3년 전
dba
558
1

If you need a solution working from PHP, the easiest way is to use the code from the CUBRID Database Schema application: http://code.google.com/p/cubrid-database-schema/

The application is open source, so you have full access to the code.

And you check how it works here: http://cubdbsch.cubrid.org/

 

링크 댓글 쓰기 (1)
답변시간 3년 전
impega
128
1

A native PHP solution would be to use cubrid_schema() function. It will return the full information including column types, constraints, indexes, primary keys, etc. All you will need to do is to build the SQL from that return value which should be easy.

링크 댓글 쓰기 (0)
답변시간 2년 전
dba
558
1

CUBRID 9.0 now supports "SHOW CREATE TABLE" statement. Here is the SHOW CREATE TABLE manual page.

링크 댓글 쓰기 (0)
답변시간 2년 전
dba
558
tagged




You are either using a very old browser or a browser that is not supported.
In order to browse cubrid.org you need to have one of the following browsers:



Internet Explorer: Mozilla Firefox: Google Chrome: