Game max fixed the number of rows in a table
Hi allI created a table that should contain only one line and avoid the possibility to add other lines to it, I used the following:
CREATE TABLE <table_name> (
<field_1> <field_type> unique,
...
<field_2> <field_type>
CONSTRAINT <field_1_ck> CHECK (<field_1> = <value>)
);
It works, but it seems a bit heavy for me... Is there a better way to define a fixed/maximum number of rows in a table?See you soon,.
Valerio
PS: how to view the code snippets in mode 'IDE-like' (i.e. fixed fonts) spaced, showing dashes, etc.?
Published by: valerio75 on February 4, 2010 01:48 - now shows the code correctly
PS: how to view the code snippets in mode 'IDE-like' (i.e. fixed fonts) spaced, showing dashes, etc.?
Put the
tag before and after your snippets.
See the [FAQ|http://forums.oracle.com/forums/help.jspa] for more information regarding tags (scroll down a bit there) .
Tags: Database
Similar Questions
-
Count the number of rows in each table
I have a list of table names, how to write a query to find out the number of rows in each table.
Select the table table_name from all_tables where owner = 'XXX' and num_row > 100
or
Select the table table_name from all_tables where owner = 'XXX' and sample_size > 100
isn't quite working.
Why?
Thanks in advance,
Published by: mpt_fz on January 12, 2010 12:06In recent versions of the db (11g):
SQL> select table_name, column_value cnt from user_tables, xmltable (('count(ora:view("'||table_name||'"))')) where table_name in ('EMP', 'DEPT', 'BONUS') / TABLE_NAME CNT ------------------------------ ----- BONUS 0 DEPT 5 EMP 14
-
Count the number of rows in a table (s)
Hi all
I have a TKT_PRIORITY_LK table that I want to count the number of rows returned by a priority level... say Low, Medium, High, critical. I want to be able to count how many of each created are they, instead returning ID instead, if making any sense... Can you please help with this.
Example; Select count (*) in TKT_PRIORITY_LK
PRIORITY group
Kind regards
Sandrine
Try this
Select a.PRIORITY, count (*) from TKT_PRIORITY_LK a, TKT_TICKET_MAIN b
where a.id = b.PRIORITY_ID
A.PRIORITY group
-
Count the number of rows in a table
Hello
I have a requirement. I want to frame a SQL, which takes the name of schema as input and returns the tables belonging to this scheme and the number of lines in a particular table.
An example of output:
===========
Can someone help me to make a request for the same.Table No. of Rows ~~~~ ~~~~~~~~ A 123 B 126 C 234 . . .
Kind regardsIf you are not sure on the statistics collected, then you need dynamic sql...
DECLARE VNUM NUMBER:=0; VSQL VARCHAR2(4000); vcount number := 0; BEGIN DBMS_OUTPUT.ENABLE(NULL); DBMS_OUTPUT.PUT_LINE(RPAD('TABLE NAME',30,' ')||' '||RPAD('ROW COUNT',10,' ')); DBMS_OUTPUT.PUT_LINE(RPAD('-',30,'-')||' '||RPAD('-',10,'-')); FOR C1 IN (SELECT TABLE_NAME,OWNER FROM ALL_TABLES WHERE OWNER='SCOTT' ORDER BY OWNER,TABLE_NAME) LOOP VSQL := 'SELECT COUNT(*) FROM '||C1.OWNER||'.'||C1.TABLE_NAME; EXECUTE IMMEDIATE VSQL INTO VNUM; DBMS_OUTPUT.PUT_LINE(RPAD(C1.TABLE_NAME,30,' ')||' '||RPAD(VNUM,10,' ')); vcount := vcount +1; END LOOP; DBMS_OUTPUT.PUT_LINE(RPAD('-',length(vcount)+6,'-')); DBMS_OUTPUT.PUT_LINE(vcount||' Rows.'); DBMS_OUTPUT.PUT_LINE(RPAD('-',length(vcount)+6,'-')); END; / TABLE NAME ROW COUNT ------------------------------ ---------- BONUS 0 DEPT 4 EMP 14 SALGRADE 5 ------- 4 Rows. ------- PL/SQL procedure successfully completed. Elapsed: 00:00:00.44
Personally, I think this is a time to kill the process... ;)
HTH,
Prazy -
function should return the number of rows in a table
Hello world
I wrote an entry function is the name of the table and the function should return how many line in the table.
the table name can change.
It is possible
Published by: Balajiraam on March 18, 2011 05:33Hello
Try this
CREATE OR REPLACE FUNCTION GETCOUNT(TABLE_NAME IN VARCHAR2) RETURN NUMBER IS TMPCOUNT NUMBER; TMPSQL VARCHAR2(1000); BEGIN TMPSQL := 'SELECT COUNT(*) FROM ' || TABLE_NAME; EXECUTE IMMEDIATE TMPSQL INTO TMPCOUNT; RETURN TMPCOUNT; END;
see you soon
VT
-
get the number of rows affected by their table top
Hello, I need to count the number of rows updated in table form. In the process of ApplyMRU, I can use the string substitution #MRU_COUNT # to show the lines updated in a success message, but I need to get this value and store it on a table. Any help would be much appreciated. Thank you.
oscarjavier99 wrote:
Hello, I need to count the number of rows updated in table form. In the process of ApplyMRU, I can use the string substitution #MRU_COUNT # to show the lines updated in a success message, but I need to get this value and store it on a table. Any help would be much appreciated. Thank you.
For that you would benefit from the APEX$ ROW_STATUS integrated substitution string.
1. create a page element display only (in my case P15_UPDATED_ROWS) Save Session State set to Yes and the Type of Condition is set to never.
2. Add a calculation after the shows with a Type of static assignment and calculation value 0 to reset the counter whenever the page is sent.
3. Add an On submit - after calculations and Validations process of PL/SQL page linked to your tabular presentation with a Status of Type PL/SQL Expression and Expression 1
:apex$row_status = 'U'
and the code of the following process ::p15_updated_rows := :p15_updated_rows + 1;
If you don't actually means "day" in the strict sense, and then change the status of process to include possible APEX$ ROW_STATUS 'C', 'U', and "D" values as needed. If you want to count all created, updated and deleted lines, do not add the condition to the process, but make sure the extended run is set to createand changed lines.
-
query table name and number of rows in a table
Hello
I am trying to create a pl/sql to insert the results of all the tables in my database and the number of rows in a table, you guys are quick scripts to do this?
Thanks in advance,
BlaisMy file of old-gold of messages from this forum:
SQL> SELECT 2 table_name, 3 TO_NUMBER( 4 EXTRACTVALUE( 5 XMLTYPE( 6 DBMS_XMLGEN.getxml('SELECT COUNT(*) c FROM '||table_name)) 7 ,'/ROWSET/ROW/C')) cnt 8 FROM user_tables; TABLE_NAME CNT ------------------------------ ---------- TEST_LONG_RAW 1 TEST_LONG_RAW_TO_BLOB 1 DEPT 4 EMP 14 BONUS 0 SALGRADE 5 TEST_DBMS_ERROR_LOG2 4 TEST_DBMS_ERROR_LOG1 6 ERR$_TEST_DBMS_ERROR_LOG2 2 DR$CTX_INDX_MULTI$I 48 TEST_MULTI_COL_SRC 4 TABLE_NAME CNT ------------------------------ ---------- DR$CTX_INDX_MULTI$R 22 EMP_TEST 14 DR$CTX_INDX_MULTI$K 4 DR$CTX_INDX_MULTI$N 0 TEST_SQLLDR_UNICODE 4 16 rows selected. SQL>
-
Hello
How to find the number of rows in each table of a database just by using a SQL query.
and do not use the data dictionary tables also... is possible...?
Thank you
MJIt can be done in a single SQL like->
satyaki> satyaki>select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod PL/SQL Release 10.2.0.1.0 - Production CORE 10.2.0.1.0 Production TNS for Linux: Version 10.2.0.1.0 - Production NLSRTL Version 10.2.0.1.0 - Production Elapsed: 00:00:00.00 satyaki> satyaki> satyaki>SELECT table_name, 2 DBMS_XMLGEN.getxmltype ('SELECT Count(*) c FROM ' || table_name).EXTRACT ('//text()').ge tnumberval() tot_rows 3 FROM user_tables; TABLE_NAME TOT_ROWS ------------------------------ ---------- QUESTIONTYPE 0 SRGROUPTABLE 1 ST_TEST 4 REGISTER 0 DEB_1 2 EMP1 0 6 rows selected. Elapsed: 00:00:12.04
The credit goes to Michael. ;)
Kind regards.
LOULOU.
-
How to determine the number of rows in the database and save the result to a local variable?
Hello
I'm a newbie in the use of TestStand, databases and SQL, and now I've met difficulties. I use TestStand 2014 (32 bit).
I have a need to know the number of rows in a database and save that number in a local variable. I tried to practice using the database of the Types of step provided with TS. I tried to use the following in a SQL statement:
Locals.NumberOfRows = ("SELECT COUNT (*) FROM TEST_TABLE")
It returns an error: specified value is not the expected type. My goal is possible in this way, or I'm doing this completely wrong?
-RautSa
Thank you for your response, Norbert. I have a database of who wins new values at random, and sometimes I need the exact number of rows in this table.
I managed to achieve my goal by using the SQL statement: "SELECT COUNT (*) as Rowcount OF TEST_TABLE", followed by a data GET operation, which records that number of lines in a local variable.
-RautSa
-
See the number of rows affected the performance of sqlplus to a sql file
Hello
It's just we have a sql file that contains a bunch of select/update/insert statements.
I have a unix script that calls sqlplus on this sql file. However, at the exit I don't get the number of rows affected.
Without adding any code in the input sql file, how can I change the code of sqlplus shell script to print the number of rows affected for each statement in the sql file?
${ORACLE_HOME}/bin/sqlplus -L >> ${LOG_FILE} 2>&1 << EOF ${ORAID}/${ORAPASS}@${ORAINS} whenever sqlerror exit sql.sqlcode; set echo on; set feedback off; set serveroutput on; @${SQL_FILE}; exit; EOF RC=$?
The SQL_FILE of entry content is:
select 12 "col1" from dual; select 'abcd' "col2" from dual; select; select 13 'col3' from dual;
The result of the race of sqlplus is (LOG_FILE):
SQL*Plus: Release 11.2.0.2.0 Production on Fri Jun 6 14:28:00 2014 Copyright (c) 1982, 2010, Oracle. All rights reserved. Enter user-name: Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> SQL> SQL> SQL> SQL> SQL> select 12 "col1" from dual; col1 ---------- 12 SQL> select 'abcd' "col2" from dual; col2 ---- abcd SQL> select; select * ERROR at line 1: ORA-00936: missing expression Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options
Thank you
Srinivas - y.
- echo setting
- Set feedback off;
use
Set of feedback on
-
How can I get the number of rows in the table using Sunopsis API target in ODI 10 g?
Hi guys,.
In fact, I want to send an alert message as soon as the interface is run from a package. I've included alert OdiSendMail that sends an email once the interface is running.
Could someone please tell how to get the number of rows inserted into the table the Sunopsis API target.
I tried to use < % = odiRef.getNbRows () % >, but this has not worked for me. Since I am a beginner, could you please help out me
This is my mail to send ODI format
"The population of data managed to < % = odiRef.getSysDate () % >
Total of lines in the target table is: < - need an API code-> "
Kind regards
Clinton
Published by: LawrenceClinton on February 25, 2013 20:53Hello
Create the project with details below variable
Nom_de_variable: Total_Row_Count
Type of variable: Variable discount
Definition tab:
Data type: digital
Action: No persistentRefresh the tab:
Schema: provide the schema of your repository to work and beSELECT log.nb_row
THE journal of snp_step_log, snp_scen_step step
WHERE log.nno = step.nno
AND step.scen_no = (SELECT scen_no FROM snp_scen_step WHERE step_name='<%=odiRef.getPrevStepLog ('STEP_NAME") % > ')
AND log.sess_no = '< % = odiRef.getSession ("SESS_NO") % >' code at low
AND step.step_name = ' < % = odiRef.getPrevStepLog ("STEP_NAME") % > 'Note: add this variable after the stage of interface in your package (after the interface anywhere you can place), you can add this variable before ODISendEmailNotification in your package
call this varciable * #Total_Row_Count * in the Notification of ODISendEmail
for example :
Data has been fulfilled successfully in < % = odiRef.getSysDate () % >
Total no of lines filled are: * #Total_Row_Count *it will work
cordially,
Phanikanthedited by: Phanikanth on February 28, 2013 01:13
edited by: Phanikanth on February 28, 2013 01:14
-
Displays the number of rows in the table displaying a named criteria query data
I created a test named for my View, called 'Criteria1' and Criteria1 to create a group of ADF with Table query. I want to display the number of rows in result when a search is performed. How can I do?
Thanks in advance,
TomAs mentioned, you can add outputText and you must give OutputText partialTriggers as query component your Id. Thus, when you give a search on the query component, it will refresh the outputText with the number of lines.
ID = "ot1" partialTriggers = "id of the component of motion here" / > "" -
Get the number of rows in the oracle table
Hi all
I want to get the total number of rows in the sql to the appmodule table.
After you apply the criteria to view some on the view object. If he try with getallrowsinrange the number of rows found within the viewobject was but I want a total number of rows in the sql table.
How can I get that
I use jdev 11.1.1.5
Thanks in advanceI threw something together, quick and dirty, don't hesitate to optimize.
Assuming you want the County table, I put the code in a subclass of EntityDefImpl since it is representing a table in the middle tier.
public class EmpDefImpl extends EntityDefImpl { /** * This is the default constructor (do not remove). */ public EmpDefImpl( ) {} //~ Methods **************************************************************************** public long getTableRowCount( DBTransaction transaction ) { String query = getQuery( ); String countQuery = String.format( "SELECT COUNT(*) FROM (%s)", query ); long count = 0; ViewObject vo = transaction.createViewObjectFromQueryStmt( countQuery ); try { vo.executeQuery( ); Row row = vo.first( ); Number number = (Number)row.getAttribute( 0 ); count = number.longValue( ); } finally { vo.remove( ); } return count; } }
Depending on your card type, you may not get an oracle.jbo.domain.Number, but something else, so the cast may need correction.
Usage example:
public class EmpEditViewImpl extends ViewObjectImpl { public EmpEditViewImpl() { } protected void executeQueryForCollection( Object object, Object[] object2, int i ) { super.executeQueryForCollection( object, object2, i ); EmpDefImpl def = ( EmpDefImpl )getEntityDef( 0 ); long tableRowCount = def.getTableRowCount( getDBTransaction() ) ); // Do something with it } }
As you can see, the code is fairly generic. Also, you might be able to put this in a base extension ADF class.
Sascha
Published by: Sascha Herrmann on June 7, 2012 14:39
-
to check the number of rows affected by an update query in a procedure
Hello
I want to check the number of rows affected by the update script that I used in a procedure and I shoud be able to use this count towards the end of the procedure.
How can I do?
for example:
create or replace procedure p1 is
Start
Update table1 set x = 'a', where y = 'b ';.
end p1;
Published by: christele CS on May 1, 2012 22:06Hello
Try the below a...
create or replace procedure p1 is
Start
Update table1 set x = 'a', where y = 'b ';.
dbms_output.put_line (SQL % ROWCOUNT |) ("Lines updated ');
end p1; -
Count the number of rows returned from each view in USER_VIEWS
For each USER_VIEWS view, I would return the name, creation date, last modified dateand the number of rows returned by this view.
Here's what I have so far:
Returns:col object_name format a20 select object_name, created, last_ddl_time from user_objects where object_type = 'VIEW'
How can I add a last column that counts the number of rows returned by this view?OBJECT_NAME CREATED LAST_DDL_TIME -------------------- --------- ------------- AISLE_AVG 11-FEB-12 11-FEB-12 COURSE_AVG 11-FEB-12 20-FEB-12 EXE_12_VIEW 11-FEB-12 21-FEB-12 L1_P2 17-FEB-12 17-FEB-12 L1_P3 17-FEB-12 17-FEB-12 L1_P4 17-FEB-12 17-FEB-12 L1_P5A 17-FEB-12 17-FEB-12 L1_P5B 17-FEB-12 17-FEB-12 LAB3_1A 12-FEB-12 20-FEB-12 LAB3_1B 12-FEB-12 20-FEB-12 LAB3_2A 12-FEB-12 20-FEB-12 LAB3_2B 12-FEB-12 20-FEB-12 LAB5_1 19-FEB-12 19-FEB-12 LAB5_2 19-FEB-12 19-FEB-12 LAB5_3 19-FEB-12 19-FEB-12 LAB5_4 19-FEB-12 19-FEB-12 LAB5_5 19-FEB-12 19-FEB-12 LAB5_TIMES 19-FEB-12 19-FEB-12 LAB6_1 19-FEB-12 19-FEB-12 LAB7_VIEW 20-FEB-12 20-FEB-12 PROGRAMS 11-FEB-12 21-FEB-12 STUDENT_GPA 11-FEB-12 21-FEB-12 22 rows selected
EDIT - here is a dump of my paintings, and here are my views.
Edit2 - this is possible by using the DECODE function, by chance?The function...
CREATE OR REPLACE FUNCTION view_row_count (view_name VARCHAR2) RETURN NUMBER AS retval NUMBER; BEGIN EXECUTE IMMEDIATE 'select count(*) from '||view_name INTO retval; RETURN retval; END view_row_count; /
And now the query...
select object_name, created, last_ddl_time, view_row_count(object_name) as view_row_count from user_objects where object_type = 'VIEW'
Maybe you are looking for
-
import bookmarks from mozilla to new computer
Already transferred the files & folders of old laptop to new, but Firefox & associated bookmarks did not transfer. I downloaded Firefox on the new laptop computer, but impossible to find useful info on how to import bookmarks.
-
I can't compose or reply to messages in gmail with firefox on my mac
I have firefox version as follows: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 GTB7.1 I can't reply or compose messages in my gmail account using this browser. He gets locked in the status of "loa
-
Satellite L655D system restore problem
My laptop does not boot to windows 7, after that an Ipod is plugged into the USB port. Message "If you have recently attached a device to this computer as a camera or a portable music player, remove and restart. If you continue to get this indication
-
Sorry for my English =) I have HP Pavilion dv6-3105er, and I can't find driver for device ACPI/HPQ0004 on my product page. Recovery partition has been deleted. I think I need the HP ProtectSmart hard drive protection, but this software is missing on
-
HP LaserJet P1102W long delay between pages with narrow (4 "wide) paper stock
I use Adobe Acrobat Reader X (on Windows XP) to print a page 100 PDF on HP P1102W, with 4 "wide x 11" long paper in the main tray. There is a delay of approximately 15 seconds between pages. As soon as I share the narrow paper for regular 8.5 "x 11