|Getting Started||Documentation||Glish||Learn More||Programming||Contact Us|
|Version 1.9 Build 1556||
UPDATE table_list SET update_list [WHERE ...] [ORDERBY ...] [LIMIT ...] [OFFSET ...]updates selected rows in a table.
UPDATE vla.ms SET ANTENNA1=ANTENNA1-1, ANTENNA2=ANTENNA2-1to make the antenna numbers zero-based if accidently they were written one-based.
It is also possible to update part of an array using array indexing. E.g.
UPDATE vla.ms SET FLAG[1,1]=T UPDATE vla.ms SET FLAG[1,]=TThe first example sets only the first array element, while the second one sets an entire row in the array. The second example also shows that it is possible to set an array to a scalar value.
Type promotion and demotion will be done as much as possible. For example, an integer column can get the value of a double expression (which will be truncated).
Note that if multiple column=expression parts are given, the columns are changed in the order as specified in the update-list. It means that if an updated column is used in an expression for a later column, the new value is used when evaluating the expression. E.g. in
UPDATE vla.ms SET DATA=DATA+1, SUMD=sum(DATA)the SUMD update uses the new DATA values.
INSERT INTO table_list [(column_list)] VALUES (expr_list) INSERT INTO table_list [(column_list)] SELECT_commandThe first form adds one row to the table and puts the values given in the expression list into the columns given in the column list. If the column list is not given, it defaults to all stored columns in the table in the order as they appear in the table description. Each expression in the expression list can be as complex as needed; for example, a subquery can also be given. Note that a subquery is evaluated before the new row is added, so the new row is not taken into account if the subquery is done on the table being modified.
INSERT INTO my.ms (ANTENNA1,ANTENNA2) VALUES (0,1)adds one row, puts 0 in ANTENNA1 and 1 in ANTENNA2.
The second form evaluates the SELECT command and copies the rows
found in the selection to the table being modified (which is given
in the INTO part).
The columns used in the modified table are defined in the column list.
As above, they default to all stored columns. The columns used in the
selection have to be defined in the SELECT part of the SELECT command.
They also default to all stored columns.
INSERT INTO my.ms select FROM my.msappends all rows and columns of my.ms to itself. Please note that only the original number of rows is copied.
INSERT INTO my.ms (ANTENNA1,ANTENNA2) select ANTENNA2,ANTENNA1 FROM other.ms WHERE ANTENNA1>0copies rows from other.ms where ANTENNA1>0. It swaps the values of ANTENNA1 and ANTENNA2. All other columns are not written, thus may contain rubbish.
DELETE FROM table_list [WHERE ...] [ORDERBY ...] [LIMIT ...] [OFFSET ...]deletes some or all rows from a table.
DELETE FROM my.ms WHERE ANTENNA1>13 OR ANTENNA2>13deletes the rows matching the WHERE expression.