Assign a random value to column?

I have a Table with a single column, numeric field, about 1/2 million documents.

I want to add another column, VARCHAR2 and distributed way random value of ' a ',' B', 'C', has '.

The seed for Random can't be perfect, I just need to fill it with random data.
so that I can do a test in this Table for a different query, thank you!

Am on Oracle 10 g 2

You can try like this,

update table_name
   set column_name = chr (64 + round (dbms_random.value ( 1, 4)))

G.

Tags: Database

Similar Questions

  • Column update with random values

    Hi all

    I have a chart in which one of the columns contains the number. I want to write a script that will update the column number with different random values.

    Basically, my script should take the first line of a table and should update with a random value in the second loop, it must update the column with a random value.

    I need a simple PL SQL code to do this.

    Thanks in advance.

    Thank you.

    Kind regards
    Dirasa

    or

    update table_name set column_name=round(dbms_random.value(1,100));
    

    Do not loop, this single update statement will satisfy your need by your request above.

    arguments passed in 1 100 are the lower and upper limit to generate random numbers. like 5,1,45,64,23 etc.

    Sample of run...

    PRAZY@11gR1> select * from test;
    
            ID
    ----------
             1
             2
             3
             4
             5
    
    Elapsed: 00:00:00.00
    PRAZY@11gR1> update test set id=round(dbms_random.value(1,100));
    
    5 rows updated.
    
    Elapsed: 00:00:00.00
    PRAZY@11gR1> select * from test;
    
            ID
    ----------
             2
            85
            58
            45
            27
    
    Elapsed: 00:00:00.00
    

    Kind regards
    Prazy

    Published by: Prazy on March 17, 2010 17:35

  • How to insert unique random values in 2 columns?

    I have a table with 2 columns

    Create table code_for_code)
    first_code varchar2 (10) unique not null,.
    second_code varchar2 (10) not null unique);

    and I want to make PL/SQL code to Insert unique values at random in two columns , for example 20 record... How can I do something like that?
    DECLARE
       i   NUMBER := 0;
    BEGIN
       LOOP
          INSERT INTO code_for_code
             SELECT first_code, second_code
               FROM (SELECT DBMS_RANDOM.STRING ('U', 20) first_code,
                            DBMS_RANDOM.STRING ('U', 20) second_code
                       FROM DUAL) a
              WHERE NOT EXISTS (
                       SELECT 1
                         FROM code_for_code
                        WHERE first_code = a.first_code
                          AND second_code = a.second_code);
    
          i := i + 1;
          EXIT WHEN i >= 20;
       END LOOP;
    
       COMMIT;
    END;
    
  • How to assign the text value when the data in the column is null or empty

    Hello guys

    I have a small question

    I have a column A that half of its value is empty, now the condition is that whenever the column is empty, assign "N/a" in the column... So I wrote a code which is:

    <? If: not (column A)? > column a = 'n/a' <? end if? >

    However, when I preview the RTF model, the data in the column still has not changed at all, many lines are still empty and did not show 'n/a '... The column is of type text

    Please advice

    Thank you
    N/A
    
  • How to assign a default value to a column?

    Hello

    Is it possible to alter a column in order to assign a default value for the column in the object browser?

    I have a RECORD of table in which I want to assign a value to 0 by default to a column whose type is NUMBER.

    Thank you for your kind replies.

    Christian.

    Hello

    In SQL, do something like:

    ALTER TABLE FICHE MODIFY ("Fieldname" NUMBER(n, n) DEFAULT 0 NOT NULL ENABLE)
    

    Replace Fieldname and n, n, as the case

    Andy

  • "Whereas unity" during the assignment of the width of column on InDesign Server 2015

    I am currently transfer my InDesign scripts to run on InDesign Server 2015, so far all worked well, so far.

    When I try to assign a width of a column, I get the following error:

    Error string: invalid value for the set 'width' property Unit expected, but received "1.058 mm".

    The code looks like this (listTable is my table object and iEigCol a counter in a loop for, so nothing out of the ordinary):

    var spacerColumnWidth = 1.058;
    listTable.columns[iEigCol].width = spacerColumnWidth + 'mm';
    

    A few lines earlier, I use this:

    listTable.columns[0].width = '82mm';
    

    Which works very well.

    I already tried these approaches instead:

    • By simply using the number without unit
    • Using an integer instead of a double
    • Concatenating the string before using to assign width
    • With the help of a literal string

    so far nothing worked here. Strange thing is that he works on dozens of other columns with the one of the ways mentioned to do.

    The exact same script also works very well to InDesign CS5.5.

    Any ideas what the problem may be?

    Thank you very much!

    InDesign does not set a table column width or row height under 1.058 mm (not even in the script). And in the scripts, it will not let you define under 1,059 mm. Try to work with 1,059 mm, and it should work.

  • Select the records from the first n distinct values of column

    I need to write a query in plsql to select records for the first 3 values distinct from a single column (example below, ID) and all lines for the next 3 distinct values of column and so on until the end of the number of distinct values in a column.
    for example:
    Age of name ID
    1 abc 10
    1 def 20
    2 IA 10
    2 20 JKL
    2 mno 60
    3 10 pqr
    4 the RST 10
    4 10 TÜV
    5 vwx 10
    6 10 XYZ
    hij 6 10
    7 lmn 10
    .
    .
    .
    so now... (up to a few County)
    Result must be
    1 the application should result->
    Age of name ID
    1 abc 10
    1 def 20
    2 IA 10
    2 20 JKL
    2 mno 60
    3 10 pqr

    Query 2 should lead to->
    4 the RST 10
    4 10 TÜV
    5 vwx 10
    6 10 XYZ
    hij 6 10

    Query 3 should lead to->
    7 lmn 10
    .
    .
    9... ..
    so now...
    How to write a query for this inside a loop.

    Hello

    Thus, a panel will consist of the lowest id value, the 2nd lowest and the 3rd lower, reggardless of how many lines is involved. The next group will include the 4th lowest id, the 5th lowest and the 6th lowest. To do that, you must assign the numbers 1, 2, 3, 4, 5, 6,... for the rows in order by id, with all lines with the same id, getting the same number and without jumping all the numbers.
    This sounds like a job for the analytical DENSE_RANK function:

    WITH     got_grp_id     AS
    (
         SELECT     id, name, age
         ,     CEIL ( DENSE_RANK () OVER (ORDER BY id)
                   / 3
                   )          AS grp_id
         FROM     table_x
    )
    SELECT     id, name, age
    FROM     got_grp_id
    WHERE     id     = 1     -- or whatever number you want
    ;
    

    If you would care to post CREATE TABLE and INSERT statements for your sample data, then I could test it.
    See the FAQ forum {message identifier: = 9360002}

  • random values

    I want to create random values for a particular column.

    create table employee1 (empno, ename varchar2 (50), eword varchar2 (5), issue 4, tdate date default sysdate);


    Insert into employee1 (4200, 'Hyderabad1', random, sysdate values);


    the random value should be 5 digit only.
    No spaces.
    create table employee1(empno number(4), ename varchar2(50), eword varchar2(5), tdate date default sysdate);
    insert into employee1 values (4200,'Hyderabad1',dbms_random.string('X',5) , sysdate);
    
    1 rows inserted
    
    select * from employee1
    
    EMPNO                  ENAME                                              EWORD TDATE
    ---------------------- -------------------------------------------------- ----- -------------------------
    4200                   Hyderabad1                                         QWBIR 03-MAY-12                 
    
    1 rows selected
    
  • DMA FIFO - random values?

    iHi.

    My apologies if this is the wrong Board... not sure where it should go! Just to clarify from the outset, I cannot share screws due to issues of IP etc... sigh.

    Basically I have a sbRio 9626 and the software that runs on the FPGA to interface with analog converters / digital external. This is done using a machine to States (single cycle loop timed with a structure of business inside, so it passes between cases each tick of the clock FPGA). In one of the cases (the States), I have a little routine that takes data from the ADC and place it in a buffer FIFO of DMA of target-to-host. In fact, there are 4 FIFO DMA buffers to send various information and the value of the sample. It is then read by the software on the host of RT and processed to produce an array of values which I then send to the PC using a shared variable.

    What I wanted to check, is that data sent from FPGA to RT host (and PC) are contiguous (that is, I have my right to lengths FIFO). I modified the code FPGA to use a counter instead of the data sampled for the FIFO must simply send numbers in a sequence (1, 2, 3, 4, etc.). I then examine this sequence to ensure that it is correct, and no data has been overwritten.

    I think it's the FIFOs, 2, 3 and 4 are very good. FIFO 1 sends data that is continuous but every now and then I seem to get a glitch at random. This glitch is * not * appear to be due to lengths of FIFO, but seems to be an error in the data transfer. For example, I get something like 1, 2, 3, x, 5, 6, 7, y with x and y the seemingly random values. The positions x and y in the sequence are also seemingly random - they have not held in the same place every time. Code written to the FIFO 1 is * exactly * the same thing others - in fact, it's the same group of data being written.

    Has anyone seen anything like this before? I am trying to determine if it is due to the goal to receive FIFO or some problem with the shared variable in the network. Any suggestions as to what I could check? It almost seems as if there is IME peaks on the transfer... does not suggest this is the case but it gives an idea of what I see. I'm using Labview 2013 and BIOS on the sbRio is up-to-date. I have sbRio another I'll try again later to see if the problem is specific to a particular board.

    It seems that you have found the wrong path here: since you are dealing with the programming of FPGA, which is essentially played woth LabVIEW you should post this question to the Office of LabVIEW or, perhaps, to the Office LabVIEW Embedded

  • Random values in the transmission of TCP

    Hello

    I capture a unique setting in grayscale (160 x 120) and sent via TCP to a C program. The problem is that, before the reading of the values of actual pixels in the console, the first 8 bytes is composed of some two random values "120" and "160", as shown in the image below. It seems that these two values are 32-bit unsigned integers, since each represents 4 bytes. The values come from the LabVIEW code below?

    Have you not already answered this in your original message thread?  http://forums.NI.com/T5/LabVIEW/sending-8-bit-unsigned-integer-in-LabVIEW/m-p/2695753

    That you marked as resolved?

    The one where it was mentioned that flatten chain has an entry on whether or not you want to prepend the size of tables?

    Do you really think the values of 160 and 120 'random' when in your post you mentioned even you have a table of 160 x 120?

  • change the color of line based on the value of column 5 Apex in the classic report

    Version of the apex 5.0.0.00.31

    Standard universal theme

    Page theme default template

    Classic report

    Foldable report template

    Hello

    I know this question has been asked several times here, but I'm working on 5 Apex and need to know the correct way to do it in this version.

    I need to change the color of the text of the entire line (no background color) based on the value in one of the columns of the classic report. I have just two conditions, if the value of column = Yes, color should be red, otherwise it must be green.

    I am new to jscript and css, so appreciate if someone can tell me the solution with steps.

    I have already checked this link that changes the value of the column, need to do something similar to the whole line.

    https://tylermuth.WordPress.com/2007/12/01/conditional-column-formatting-in-apex/

    Hi coolmaddy007-Oracle,.

    Here's an example set up on the apex.oracle.com according to the specifications you gave: https://apex.oracle.com/pls/apex/f?p=35467:1

    Version of the apex 5.0.0.00.31

    Standard universal theme

    Page theme default template

    Classic report

    Foldable report template

    Here is how it is done:

    Create a dynamic action with the following specifications:

    Name: Give the appropriate name

    Event: After refresh

    Selection type: region

    Region: select your region classic report

    Condition: No strings attached

    Action: Run the JavaScript Code

    Fire on loading the Page: Yes

    Code:

    $('td[headers="JOB"]').each(function() {
      if ( $(this).text() === 'MANAGER' ) {
        $(this).closest('tr').find('td').css({"color":"red"});
      }
      if ( $(this).text() === 'SALESMAN' ) {
        $(this).closest('tr').find('td').css({"color":"green"});
      }
      if ( $(this).text() === 'CLERK' ) {
        $(this).closest('tr').find('td').css({"color":"blue"});
      }
    });
    

    NOTE: Download the selector appropriate for your knowledge $('td[headers="JOB"]') case using firebug/browser development tools.

    Items concerned: leave blank.

    PS: Changed the example to change the color of text instead of the background color.

    I hope this helps!

    Kind regards

    Kiran

  • How to assign the next value in the sequence directly in a variable?

    How to assign the next value in the sequence directly in a variable without using a table TWICE in PL/SQL.

    BluShadow wrote:

    How about a quick test on 11g, just to see if you directly select a sequence in a variable is significantly better than the mark of DOUBLE.

    ...

    Nope... no obvious difference.

    This is because there is none: Oracle's SELECT sequence. NEXTVAL FROM DUAL under the covers. The direct assignment is just a convenient encoding for us, but it does not change the work that accomplishes Oracle.

    create sequence s;
    alter system flush shared_pool;
    declare
    l_num number;
    begin
    l_num := s.nextval;
    end;
    /
    select sql_text from v$sql where parsing_schema_name = user;
    
    SQL_TEXT
    Report the number of l_num; begin l_num: = s.nextval; end;
    Select sql_text from v$ sql where parsing_schema_name = user
    Select double S.NEXTVAL
  • Duplicate in the same random value in the composition.

    Is this possible? How can I do with expressions?

    Thank you.

    Well, nothing prevents you to just spit a random value on a global scale, then by linking all your other expressions to it. And the random() method accepts arrays as well if you want it spit only specific predetermined values. You need to read about such things. It is not still own EI, just generic JavaScript.

    Mylenium

  • Dictionary of data values in column view (s)

    The following query is the list of the most fragmented tables.

    My question is that I do not understand why the value of the blocks is multiplied by 8. Is because the value of column of blocks show a kilo byte? so convert us kilo bits?

    My second question is, what is the value of these columns represent in general? In other words, when I look at the data of avg_row_len how can I understand the which type of data it represent?

    For example: avg_row_len, the number in this column represents byte? or kilobye?

    select table_name,round((blocks*8),2) "size (kb)" ,
                      round((num_rows*avg_row_len/1024),2) "actual_data (kb)",
                     (round((blocks*8),2) - round((num_rows*avg_row_len/1024),2)) "wasted_space (kb)"
    from dba_tables
    where (round((blocks*8),2) > round((num_rows*avg_row_len/1024),2))
    order by 4 desc

    Thanks in advance.

    So what you don't understand? Num_Rows * avg_row_len gives "average you" number of bytes occupied by the data in the table. Num_Rows * avg_row_len/1024 is same in KB. And round ((num_rows*avg_row_len/1024), 2) round it to two decimal places. blocks * 8 (as I said, code you posted assume table block size is 8K) is the space allocated to the table in KB. And I have no idea why code is rounded, something that is whole number to start.

    SY.

  • Request to remove row where the value of column contains alphabets

    Hello

    Could someone please help me to get this application working.

    Request to remove row where the value of column contains alphabets.

    DELETE FROM BIN_ITEM WHERE order_nmb LIKE '% [A - Z] % ' | LIKE '% [a - z] %'

    Thank you and best regards,

    Madam.

    SELECT order_nmb FROM BIN_ITEM WHERE regexp_count(order_nmb,'[0-9]') = 0

    ----

    Ramin Hashimzade

Maybe you are looking for