VIM g between two search strings - vim

I have the following general structure repeated in a document I'm editing with VIM:
-- Dumping data for table `Blahblah1`
INSERT INTO `Blahblah` VALUES (....
multiple lines of insert statement
-- Table structure for table `Blahblah2`
DROP TABLE IF EXISTS `Blahblah2`;
CREATE TABLE `Blahblah2...
I'd like to use a g[lobal] search/execute to delete from the line beginning -- Dump to the blank line before the line beginning -- Table throughout the dump file. (about 25 tables)
What I've got is
:g/^-- Dumping/ ,/^-- Table/.-1d
Am I close or can anyone offer a better suggestion?
No I can't re-dump the tables. The database was MySQL and I'm converting it to SQLite manually and I don't have the MySQL db any more -- just the dump.
Essentially, I want this:
-- Table structure for table `Blahblah1`
DROP TABLE IF EXISTS `Blahblah1`;
CREATE TABLE `Blahblah1...
-- Dumping data for table `Blahblah1`
INSERT INTO `Blahblah` VALUES (....
multiple lines of insert statement
-- Table structure for table `Blahblah2`
DROP TABLE IF EXISTS `Blahblah2`;
CREATE TABLE `Blahblah2...
to turn into this:
-- Table structure for table `Blahblah1`
DROP TABLE IF EXISTS `Blahblah1`;
CREATE TABLE `Blahblah1...
-- Table structure for table `Blahblah2`
DROP TABLE IF EXISTS `Blahblah2`;
CREATE TABLE `Blahblah2...

It seems to work if you don't include the .:
:g/^-- Dumping/,/^-- Table/-1d
Also, as noted in the comments, the space before the comma is not necessary.

Related

How to overwrite source table azure Data factory

I am new to ADF. I have a pipeline which deletes all rows of any of the attributes are null. Schema : { Name, Value, Key}
I tried using a data flow with Alter Table and set both source and sink to be the same table but it always appends to the table instead of overwriting it which creates duplicate rows and the rows I want to delete still remain. Is there a way to overwrite the table.
Assuming that your table is SQL table, I have tried to overwrite the source table after deleting the specific null values. It successfully deleted the records but got the duplicate records even after exploring various methods.
So, as an alternate you can try the below methods to achieve your requirement:
By Creating new table and deleting old table:
This is my sample source table names mytable.
Alter transformation
Give new table in the sink and in settings->post SQL scripts. give the drop command to delete the source dataset. Now your sink table is your required table. drop table [dbo].[mytable]
Result table(named newtable) and old table.
Source table deleted.
Deleting null values from source table using script activity
Use script activity to delete the null values from source table.
Source table after execution.

Cassandra : Delete the data without removing the table structure

I'm running some tests on cassandra, that need the data in the table to be removed after every run. So I wrote a script that TRUNCATES the data. My question is, does it leave the table unconfigured(removes all columns) after I TRUNCATE the table? I'm a cassandra beginner. Need some insights on this.
TRUNCATE command remove all data not schema
TRUNCATE table_name;
Removes all data from the specified table immediately and irreversibly, and removes all data from any materialized views derived from that table.
Source : https://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlTruncate.html

Datastax rename table

I have deployed 9 node cluster on google cloud.
Created a table and loaded the data. Now want to change the table name.
Is there any way I can change the table name in Cassandra?
Thanks
You can't rename table name.
You have to drop the table and create again
You can use ALTER TABLE to manipulate the table metadata. Do this to change the datatype of a columns, add new columns, drop existing columns, and change table properties. The command returns no results.
Start the command with the keywords ALTER TABLE, followed by the table name, followed by the instruction: ALTER. ADD, DROP, RENAME, or WITH. See the following sections for the information each instruction require
If you need the data you can backup and restore data using copy command in cqlsh.
To Backup data :
COPY old_table_name TO 'data.csv'
To Restore data :
COPY new_table_name FROM 'data.csv'

How to use imp command for overwrite existing data

I am using the imp command for importing a database but after one time, we are executing the imp command again so that data is inserted a 2nd time. We want to remove the old data and insert fresh data.
This is what I tried...
Please help me and suggest for specific parameter which is help solved that type of problem..
thanks and sorry for my English..
IMPDP has the parameter: TABLE_EXISTS_ACTION = {SKIP | APPEND | TRUNCATE | REPLACE}
table_exists_action=skip: This says to ignore the data in the import file and leave the existing table untouched. This is the default and it is not a valid argument if you set content=data_only.
table_exists_action=append: This says to append the export data onto the existing table, leaving the existing rows and adding the new rows from the dmp file. Of course, the number and types of the data columns must match to use the append option. Just like the append hint, Oracle will not re-user any space on the freelists and the high-water mark for the table will be raised to accommodate the incoming rows.
table_exists_action=truncate: This says to truncate the existing table rows, leaving the table definition and replacing the rows from the expdp dmp file being imported. To use this option you must not have any referential integrity (constraints) on the target table. You use the table_exists_action=truncate when the existing table columns match the import table columns. The truncate option cannot be used over a db link or with a cluster table.
table_exists_action=replace: This says to delete the whole table and replace both the table definition and rows from the import dmp file. To use this option you must not have any referential integrity (constraints) on the target table. You use the table_exists_action=replace when the existing table columns do not match the import table columns.

Sybase Dropping Temporary Table

Does anybody face an issue when you drop a temporary table at the Sybase ASE 12 it still persists at a current session. So you encounter "Table already exists" when trying to select data into it again
Well, you need to read the manuals, at least the syntax for the commands you expect to use, before you write code. Otherwise you will face issues at every turn. It depends on what you are trying to do.
SELECT ... INTO #MyTable creates a table and succeeds because it does not exist. So a second SELECT ... INTO #MyTable will try to create #MyTable, find that it exists, and fail.
If you want to perform a second SELECT into the same table, TRUNCATE the table, then use SELECT ... INTO EXISTING TABLE #MyTable.
Or DROP TABLE and skip the EXISTING TABLE modifier.
If you want the table to contain the sum of several SELECTS, obviously, skip the TRUNCATE.
I normally do this:
1) CREATE TABLE #temptable (
....
)
INSERT INTO #temptable
SELECT .....
This will never give error.
This solves another possible error . If the WHERE clause accompanying the "select INTO " yields no rows, the temporary table will not have zero rows but the temporary table won't be created at all. This could make the stored proc blow up later.

Resources