How to better describe a Create Table &; PK
HelloCan you please advise me on the best method to describe a PK?
* {color: #0000ff} 1 {color} method *.
CREATE product TABLE
(
ProductID integer NOT NULL,
ProductName varchar2 (100 BYTE) NOT NULL,
CONSTRAINT PK_Product PRIMARY KEY (ProductID)
);
* {color: #0000ff} 2 {color} method *.
CREATE product TABLE
(
ProductID integer NOT NULL,
ProductName varchar2 (100 BYTE) NOT NULL
)
NOPARALLEL NOMONITORING NOCACHE LOGGING;
CREATE a UNIQUE INDEX PK_Product ON product (ProductID)
NOPARALLEL REGISTRATION;
ALTER TABLE product ADD CONSTRAINT PK_Product PRIMARY KEY (ProductID);
* {color: #0000ff} 3 {color} method *.
CREATE product TABLE
(
ProductID integer NOT NULL,
ProductName varchar2 (100 BYTE) NOT NULL
)
NOPARALLEL NOMONITORING NOCACHE LOGGING;
ALTER TABLE product ADD CONSTRAINT PK_Product PRIMARY KEY (ProductID);
{color: #ff0000} * Q1. * {color} Method3 is similar to Method2, but ignores the CREATE UNIQUE INDEX... y at - it hurt?
* {color: #ff0000} Q2. {color} * is it recommended to create constraints (PK, FK, and CHECK) in the CREATE TABLE as in Method1?
* {color: #ff0000} Q3. {color} * what tags to use to quote the code exactly as displayed in the editor? I tried to use the & #91; code & #93; Tag, but everything is reformatted into a single line that is pretty ugly.
Thank you very much in advance for any help.
Method 2 allows you to specify the storage - Tablespace and storage Clauses.
Method 3 allows yout specify the same when you use the HELP INDEXING clause.
Method 1 implicitly creates the Index in the tablespace and Table.
I do not have the recommendation to separate indexes of the Tables "of performance. If the Index is located in the Tablespace and Table, backup and recovery, and transport are simplifiied.
However if you must specify a different tablespace (remember that recovery would be a problem as you would recover two tablespaces before the table can be used), and the different storage settings (for example if still using the DMT distribution and manual), you could opt for the method 2 or 3.
Oracle provides the syntax depending on the availability of the earlier version (Oracle7 for definitions of constraints), but it is up to you, how to use it.
Published by: Hemant K grapple Sep 29, 2008 17:16
Tags: Database
Similar Questions
-
How to get data in the procedure after CREATE TABLE table1 AS SELECT * from table2
Hello
can any body tell me how to get the data in the new table created in the procedure. because it gives following error.
- Error (47,21): PL/SQL: ORA-00942: table or view does not exist
tableName: = "BCKUP_" | TO_CHAR (sysdate, 'ddmmrrrr');
tableDDL: = 'CREATE TABLE' | tableName. "AS SELECT * FROM Table1 where to_char(MSG_IN_TIME,''dd-mon-rrrr'') < sysdate - ' | daysNumber;
EXECUTE IMMEDIATE backUpDDL;
COMMIT;
DELETE FROM Table1;
How to select the data in the newly created table. as...
Select * from ". tableName;
Do not choose anything to get the number...
Just after backupDDL EXECUTE IMMEDIATE, simply refers to SQL % ROWCOUNT - who will be the number of lines.
Oh and DDL engages automatically, your commitment is redundant.
-
How to create table of the method
Hello-
Could someone please tell me how can I create an af:table with more than one column of an AppsModule method.
When I have a 1 d table return for example:
public String [] createTable()}
String [] str = new String [1];
return str;
}
I can get as a table and a column is created. But how do I get mutiple columns in a table. I want to write a method that when inserted on jsp page create table with multiple columns.
I use ADF 11 g.
Please suggest.
Greetings-
RohitHello
to do this, you use a matrix, or a list of arrays of objects. The object represents the contents of the line, e.g., person. The Person class then have setter/getter for each property you want to display in a column
Frank
-
How to specify the tablespace for a India primary key in create table statement
How to specify the storage space for a primary key index in a create table statement?
Does the following statement is true?
Thank youCREATE TABLE 'GPS'||TO_CHAR(SYSDATE+1,'YYYYMMDD') ("ID" NUMBER(10,0) NOT NULL ENABLE, "IP_ADDRESS" VARCHAR2(32 BYTE), "EQUIPMENT_ID" VARCHAR2(32 BYTE), "PACKET_DT" DATE, "PACKET" VARCHAR2(255 BYTE), "PACKET_FORMAT" VARCHAR2(32 BYTE), "SAVED_TIME" DATE DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "UDP_LOG_PK" PRIMARY KEY ("ID") TABLESPACE "INDEX_DATA" ) TABLESPACE "SBM_DATA";
Published by: qkc November 9, 2009 13:42As orafad noted, you can use the documentation using ESCALATION clause, i.e.
SQL> ed Wrote file afiedt.buf 1 CREATE TABLE GPS 2 ("ID" NUMBER(10,0) NOT NULL ENABLE, 3 "IP_ADDRESS" VARCHAR2(32 BYTE), 4 "EQUIPMENT_ID" VARCHAR2(32 BYTE), 5 "PACKET_DT" DATE, 6 "PACKET" VARCHAR2(255 BYTE), 7 "PACKET_FORMAT" VARCHAR2(32 BYTE), 8 "SAVED_TIME" DATE DEFAULT CURRENT_TIMESTAMP, 9 CONSTRAINT "UDP_LOG_PK" PRIMARY KEY ("ID") USING INDEX TABLESP ACE "USERS" 10 ) 11* TABLESPACE "USERS" SQL> / Table created.
Justin
-
How to know the date of the created table
Hello
How will I know when a table has been created in oracle 9i and 10g.
thxsselect created from dba_objects where object_name = 'tablename';
- - - - - - - - - - - - - - - - - - - - -
Kamran Agayev a. (10g OCP)
http://kamranagayev.WordPress.com -
As sysdba, how to grant create table to a user for a particular tablespace?
I did the PRACTICE tablespace and user SEAN. How can I give SEAN the privilege to create a table in the practical tablespace?
CREATE TABLESPACE PRACTICE
DATA FILE
' F:\DBM\FALLB\DB2046\ORACLE\ADMIN\ORAC...
SIZE 20 M
DEFAULT STORAGE OF DICTIONARY OF MANAGEMENT MEASURE (1 M INITIAL FOLLOWING 1 M MAXEXTENTS 20 PCTINCREASE 0);
CREATE USER SEAN
IDENTIFIED BY SEAN
PRACTICE OF TABLESPACE DEFAULT;
GRANT CREATE SESSION TO SEAN;
-----------------------------------------------
-----------------------------------------------
SEAN GRANT SYSDBA;
+
Sean/[email protected] CONNECT as sysdba
Works, but what happens if I don't want SEAN have sysdba privileges?
-----------------------------------------------
-----------------------------------------------
Another question would be if I don't give SEAN sysdba privileges and then I connect like sean and then perform a
SELECT * FROM TAB;
to display the available tables, how can I do so that I can only see the paintings I do myself instead of all tables in the database?Hello
Connect as sys and grant after privs to SEAN, I added a few privileges as well.
Do not give any user other than SYS sysdba priv, unless you intend to use user SEAN as a user administrative addition to SYS.
GRANT RESOURCE TO SEAN; GRANT CONNECT TO SEAN; GRANT CREATE SESION TO SEAN; -- GRANT UNLIMITED TABLESPACE TO SEAN; GRANT CREATE VIEW TO SEAN; GRANT CREATE PROCEDURE TO SEAN ; GRANT CREATE TABLE TO SEAN -- 1 Tablespace Quota for SEAN ALTER USER SEAN QUOTA UNLIMITED ON PRACTICE;
Concerning
-
How to force the data type in create table field?
Hi all
I need to force my table to create as follows
Create table XYZ
(Test varchar2 (10 CHAR)
...
);
When I run my Interface the script is
Create table XYZ
(Test varchar2 (10))
...
);
and the DBMS translated into
Create table XYZ
(Test varchar2 (10 BYTE),
...
);
I have the same problem with I$, C$, and so on.
Best regards
Marco
Hi all
I fix my problem:
In Phisical Tecnology, under ORACLE Tecnology, data TYPE, I modified the definition of VARCHAR2 in VARCHAR2(%L CHAR).
(Before it was VARCHAR2 (%)).
Thank you all.
Marco
-
How can I select stuff of table has created in the PL/SQL script?
When I execute a select statement, SQLplus complains of the table does not exist. But it has been created? Don't know what goes wrong... Thanks in advance...
The code is as follows:
DECLARE
column_table varchar (50): = "column_table";
r_count NUMBER (10): = 0;
BEGIN
column_table: = UPPER (column_table);
-I created the table here and validation
IMMEDIATELY RUN 'CREATE TABLE' | column_table | "(varchar2 (100) from table_name, column_name varchar2 (1000))';
commit;
IF someCondition THEN
Bonneau
-It's where SQLPLUS complains about the table or view does not exist
Select count (1) in the column_table r_count where table_name = someValue;
Bonneau
END IF;
END;
/You will need to use dynamic sql to access objects created by using dynamic sql.
>
Select count (1) in the column_table r_count where table_name = someValue;
>
During this "compilation" the table declaration that it is trying to reference does not exist then you get an error.The table does exist when the code is executed.
-
Creating table and use - part 1
be no difficulty with arrays in C, etc. but creating tables of LabVIEW poisoned me. Unfortunately, the heart I sure table labs start out with a table already in place is not much help either. For example, in the attachment, I have a simple loop generating a series of figures that I want to put in a picture. I place a table on the block diagram and its type sucks and I can't find a good way to change it. The textbook says to drag an object in the table on the front panel. So, how is - a hang out an integer in an array?
Thank you
JVH
jvh75021 wrote:
Thanks for the post. Where did you get the constant that you drag in the table?I'll try to help in this form:
Darren wrote:
If you know the name of the object you want, you don't have to look at all the pallets.
Amazing that NEITHER use YouTube for video hosting, because it is blocked by the firewall of our company.
Andrey.
-
How can I write in a table cell (row, column appear) in a databae?
How can I write in a table cell (row, column appear) in a database using LabVIEW Database Toolkit? I use Ms Access. Suppose I have three columns in a table, I write 1 row of the 1st column, then 1st rank of the 3rd column. The problem I have is after writing the 1st column of 1st row, the reference goes to the second row, and if I write in the 3rd column, he goes to the 2nd row 3rd column. Any suggestion?
When you perform a SQL INSERT command, you create a new line. If you want to change an existing line, you must use the UPDATE command (i.e. UPDATE tablename SET column = value WHERE some_column = some_value). The some_column could be the unique ID of each line, date and time, etc.
I don't know what is the function to use in the Toolbox to execute a SQL command, since I do not use the Toolbox. Also, I don't understand why you don't do a single INSERT. It would be much faster.
-
FREELISTS and FREELIST GROUPS of CREATE TABLE
My oracle 10g, create table statement is below:
CREATE TABLE S005. Test
(
AAA char (1)
)
PCTFREE 0
STORAGE)
FREELISTS 10
FREELIST GROUPS 20
)
LOGGING
NOCACHE
NOPARALLEL
NOMONITORING;
After performing this sql, I have a query table USER_TABLES but FREELISTS and FREELIST_GROUPS fields show nothing.
In my view, FREELISTS value must be 10, and FREELIST_GROUPS should be 20. How to retrieve these values?
Thank you very much
-
How to add data to the table using Manager POST for restful Apex application
Hi all
I managed to create a service application web Manager restful using GET for the Restful service module. I am able to get the data in row on the presentation of a table row id in the application. But I can't find an appropriate example, how the new data in the table can be posted or deleted. I created a POST handler for a URI scheme and look forward on how to proceed. Any help would be really appreciated.
Source for the POST Manager:
Start
insert into ALL_BOOKS values(:id,:book);
end;
Also created 2 parameters id and the book.
Hi jerry2134,
jerry2134 wrote:
I managed to create a service application web Manager restful using GET for the Restful service module. I am able to get the data in row on the presentation of a table row id in the application. But I can't find an appropriate example, how the new data in the table can be posted or deleted. I created a POST handler for a URI scheme and look forward on how to proceed. Any help would be really appreciated.
Source for the POST Manager:
Start
insert into ALL_BOOKS values(:id,:book);
end;
Also created 2 parameters id and the book.
Check out the following tutorials OBE, that explains the creation of GET and POST RESTful Web Services and how to use them in the APEX.
- Creation and use of RESTful Web application services Express 4.2
- Creation and use of RESTful Web application services Express 5.0
Also what yo mean "looking forward on how to proceed? Do you want to or created for use/consume in your Oracle APEX application hosted RESTful web services?
If Yes, in your Application, you must create a RESTful Web Service reference -> shared components. Then, create a form/report based on Web Service reference.
Kind regards
Kiran
-
How to MERGE when the target table contains invisible columns?
Oracle running on Oracle Linux 6.4 12.1.0.2.0 database:
During his studies of FUSION with invisible columns, I discovered that invisible columns in the target table cannot be read. Workaround seems to be
MERGE INTO (SELECT <column list> FROM <target table>) AS <alias>
However, the documentation does not seem to allow this. Here are the details.
Test data
> CREATE TABLE t_target( k1 NUMBER PRIMARY KEY, c1 NUMBER, i1 NUMBER invisible ) table T_TARGET created. > INSERT INTO t_target (k1,c1,i1) SELECT 2, 2, 2 FROM dual UNION ALL SELECT 3, 3, 3 FROM dual UNION ALL SELECT 4, 4, 4 FROM dual 3 rows inserted. > CREATE TABLE t_source( k1 NUMBER PRIMARY KEY, c1 NUMBER, i1 NUMBER invisible ) table T_SOURCE created. > INSERT INTO t_source (k1,c1,i1) SELECT 1, 1, 1 FROM dual UNION ALL SELECT 2, 2, 9999 FROM dual UNION ALL SELECT 3, 3, 3 FROM dual 3 rows inserted.
First try
Please note that I have a WHERE clause in the WHEN MATCHED clause. Its purpose is to avoid the update of a row when data are already correct. The WHERE clause is trying to read the invisible column of the target table.
> MERGE INTO t_target o USING ( SELECT k1, c1, i1 FROM t_source ) n ON (o.k1 = n.k1) WHEN MATCHED THEN UPDATE SET c1=n.c1, i1=n.i1 WHERE 1 IN ( decode(o.c1,n.c1,0,1), decode(o.i1,n.i1,0,1) ) WHEN NOT MATCHED THEN INSERT (k1, c1, i1) VALUES(n.k1, n.c1, n.i1) ... Error at Command Line : 10 Column : 12 Error report - SQL Error: ORA-00904: "O"."I1": invalid identifier
As you can see, I put a subquery after the USING clause so that 'n.i1' would be 'visible', but this is not enough since the 'I1' column in the target table is always invisible.
Second test
> MERGE INTO ( SELECT k1, c1, i1 FROM t_target ) o USING ( SELECT k1, c1, i1 FROM t_source ) n ON (o.k1 = n.k1) WHEN MATCHED THEN UPDATE SET c1=n.c1, i1=n.i1 WHERE 1 IN ( decode(o.c1,n.c1,0,1), decode(o.i1,n.i1,0,1) ) WHEN NOT MATCHED THEN INSERT (k1, c1, i1) VALUES(n.k1, n.c1, n.i1) 2 rows merged.
Here I used a subquery in the INTO clause thus, and it worked.
Unfortunately, this does not seem to be admitted in the documentation: IN fact refers to a table or a view as schema objects.
My question is:
How can I refer to invisible columns in the target table without creating a new object? My workaround using a subquery solution seems to work very well, but can I recommend if it is not documented?
Can I replace a "inline view" for a view and still be supported?
During his studies of FUSION with invisible columns, I discovered that invisible columns in the target table cannot be read. Workaround seems to be
However, the documentation does not seem to allow this. Here are the details.
Here I used a subquery in the INTO clause thus, and it worked.
Unfortunately, this does not seem to be admitted in the documentation: IN fact refers to a table or a view as schema objects.
My question is:
How can I refer to invisible columns in the target table without creating a new object? My workaround using a subquery solution seems to work very well, but can I recommend if it is not documented?
Can I replace a "inline view" for a view and still be supported?
But the documentation DO ALLOWS not only! You use a view - a view online and those that can be changed in a MERGE statement.
All versions of the doc for FUSION since 9i specifically say this:
INTO clause
Use the
INTO
target clause to specify the table or view you are updating or inserting into. To merge the data in a view, the view must be updated. Please refer to the "Notes on the editable views" for more information.Here are the links for the doc. 9i, 10g, 11g and c 12, ALL OF THEM (the last three), except 9i have this EXACT clause above.
SQL statements: INDICATED to ROLLBACK FALLS, 15 of 19
http://docs.Oracle.com/CD/B19306_01/server.102/b14200/statements_9016.htm
http://docs.Oracle.com/CD/B28359_01/server.111/b28286/statements_9016.htm
https://docs.Oracle.com/database/121/SQLRF/statements_9016.htm
9i doc does not have this specific quote in the INTO clause section, but it doesn't have that quote a little later:
Limitation of the update of a view
- You cannot specify
DEFAULT
when refreshing a view. - You cannot update a column referenced in the
ON
condition
clause.
merge_insert_clause
The
merge_insert_clause
specifies the values to insert into the column of the target table, if the condition of theON
clause is false. If the insert clause is executed, then all insert triggers defined on the target table are activated.Restrictions on the merger in a view
You cannot specify
DEFAULT
when refreshing a view.If your "workaround" isn't really a workaround solution. You SHOULD use an inline view if you need to reference a column "invisible" in the target table, since otherwise, these columns are INVISIBLE!
My workaround using a subquery solution seems to work very well, but can I recommend if it is not documented?
You can recomment it because IT IS documented.
- You cannot specify
-
using datediff, creating table
Hi all
I'm trying to calculate the number of years of a product when a new record is inserted.
That's what I tried
CREATE TABLE WaterMeter)
meterID VARCHAR (25) NOT NULL,
readingID VARCHAR (25) NOT NULL,
meterSerialNum VARCHAR (25) NOT NULL,
installationDate DATE NOT NULL,
noOfYears AS (DATEDIFF (YEAR, sysdate, installationDate));
CONSTRAINT watermeter_Pkey PRIMARY KEY (meterID).
Watermeter_Altkey of UNIQUE CONSTRAINT (meterSerialNum)
);
and the following error appeared.
Error in the command line column: 6:27
Error report:
SQL error: ORA-00904: "YEAR": invalid identifier
00904, 00000 - '% s: invalid identifier '.
* Cause:
* Action:
so, how can I go around to solve this issue?
Virtual column is... virtual. It is not stored in the table. Oracle calculates the value of virtual column every time that reference you it. This is why you cannot use functions such as SYSDATE in a virtual column expression. I understand the logic underlying your table, but this is done using views. Simply create the table without column of noOfYears, then
create or replace view WaterMeter_VW as select t.*, MONTHS_BETWEEN (sysdate, installationDate) / 12 WaterMeter noOfYears t;
SY.
-
Creating table in the desired tablespace
Hello
I created the CUZK_BACKUP tablespace:
CREATE the TABLESPACE CUZK_BACKUP DATAFILE ' / oradata/RUIAN/cuzk_backup01.dbf' SIZE 3 G AUTOEXTEND ON NEXT 100 M MAXSIZE 15 G;Now I'm trying to create table in this space of table like this:BEGIN
-zjisti, if jiz existuji tabulky ve schematu centrumadmin (0 - no, 1 - year)
SELECT COUNT (*) in the nCount_aud FROM dba_tables owner WHERE to = 'CENTRUMADMIN' and table_name = "$ _BACKUP2";
SELECT COUNT (*) in the nCount_fga FROM dba_tables owner WHERE = 'CENTRUMADMIN' and table_name = "FGA_LOG$ _BACKUP2";
IF (nCount_aud < = 0)-pokud tabulka neexistuje, vytvor ji partisnovanou po mesici
THEN
v_sql_aud: =' CREATE TABLE CENTRUMADMIN. AUD$ _BACKUP2
TABLESPACE CUZK_BACKUP
storage (initial 500 m next 50 m maxextents unlimited)
PARTITION BY RANGE (NTIMESTAMP #)
INTERVAL (NUMTOYMINTERVAL (1, "MONTHS"))
(
P_2013 PARTITION VALUES LOWER THAN (TO_DATE ("01/01/2014", "DD-MM-YYYY"));
P_2014_01 PARTITION VALUES LOWER THAN (TO_DATE ("02/01/2014", "DD-MM-YYYY"));
P_2014_02 PARTITION VALUES LOWER THAN (TO_DATE ("03/01/2014", "DD-MM-YYYY"));
P_2014_03 PARTITION VALUES LOWER THAN (TO_DATE ("04/01/2014", "DD-MM-YYYY"));
P_2014_04 PARTITION VALUES LOWER THAN (TO_DATE ("05/01/2014", "DD-MM-YYYY"));
P_2014_05 PARTITION VALUES LESS THAN (TO_DATE ("06/01/2014", "DD-MM-YYYY")))
AS select * from SYS. AUD$ where 1 = 2';
EXECUTE IMMEDIATE v_sql_aud;
DBMS_OUTPUT. Put_line ('Vytvorena tabulka CENTRUMADMIN.) AUD$ _BACKUP2.') ;
ON THE OTHER
DBMS_OUTPUT. Put_line (' CENTRUMADMIN Tabulka.) AUD$ _BACKUP2 jiz existuje.') ;
END IF;
Table is created, but not in the CUZK_BACKUP tablespace:
Select table_name, tablespace_name from dba_tables where owner = "CENTRUMADMIN";
TABLE_NAME, TABLESPACE_NAME
------------------------------ ------------------------------
CUZK_SLUZBY OKO_USR_SCD
CUZK_LOG_BEHU OKO_USR_SCD
CUZK_LOG_FAZE OKO_USR_SCD
CUZK_LOG_CHYBY OKO_USR_SCD
AUD$ _BACKUP
AUD$ _BACKUP2
FGA_LOG$ _BACKUP
FGA_LOG$ _BACKUP2
Why there is no tablespace and how to make it work?
Thank you
Honza
For a partitioned table, the actual segments are at the Partition level. If a query DBA_TAB_PARTITIONS and DBA_SEGMENTS.
Hemant K Collette
Maybe you are looking for
-
AT100 - impossible to get my calendar to store the dates of the annual events
Hello. Cannot get my calendar to store the dates of the annual events birthdays for example.Option gives (annual 27 July 2012), but would it be fair (27 July each year). No way to remove year so presumably won't wait that 2012 will come along! All th
-
Hello. Im sure most of the people are getting bored with my frequent messages but I was wondering what I need to know to upgrade my diet or if someone can link me to a decent PSU. Im trying to run a graphics at least 512 MB of memory and all the maps
-
Save the data of State machine after each iteration, then write all the data at once
I have trouble finding in the best way to manage data generated by my state machine. Here are the data that it will save: * When pressure is set, a set point is returned. * When the pressure is set, a reading is taken a multimeter. What would be the
-
Error message Scanner HP 7500 has large Format
I have a 1 - year, 7500 HP all-in-One printer/scanner/copier/fax. 3 months ago the bar scanner has started making a grunting noise when its start and restart and then suddenly stuck. I have fiddeled autour and I've tried doing a hard reboot by pull
-
Hi all I just upgraded to 10.2.0424. Since upgrading my email imap accounts no longer work. When I go into settings all say not connected. When I select one it says that an unexpected problem has produced with - some features doesn't work maybe not p