Is it possible to execute a command that removes all tables from sql ce database?
thanks for the help
You can use SCHEMA to create a script:
select 'drop table ' || table_name || ';' from information_schema.tables;
Then run the script. You may need to run the script several times because SQLCE does not have the CASCADE (AFAIK) option .
System.IO.File.Delete, and then run the required CREATE TABLE scripts
, , .
:
CreateTables.sqlce
Paste the following into the PowerShell console:
function GenerateDropScript($DbSchemaFile) { function Reverse($inputArr) { $arr = @($inputArr) [array]::Reverse($arr) return $arr } $TableNames = Get-Content $DbSchemaFile | ? { $_.StartsWith('CREATE TABLE') } | % { $_.Substring(14).Replace('] (', '') } $ReverseNames = Reverse($TableNames) "Generating DROP script for all tables in: `n`t$DbSchemaFile`n" $ReverseNames | % { "DROP TABLE [$_]; GO;" } }
Run GenerateDropScript CreateTables.sqlce
GenerateDropScript CreateTables.sqlce
This will read the CREATE Script and generate DROP scripts for all tables in the reverse order that they are created, so you will not get any dependency errors.
Source: https://habr.com/ru/post/1772848/More articles:Unexpected results from OpenMP on i7 and Xeon - cCreating a domain name check - c #XAML Based Viewer for ASP.NET MVC - asp.netob_start () in the loop - phpDebugging a Java program from Tomcat (JSP) - javaHow to implement anti-aliasing in the frequency domain? - c #How to disable errors / warnings in Eclipse due to OpenCL / CUDA syntax? - eclipseIs xVal deprecated with MVC 2? - validationsetting / changing rail configuration values ββafter initialization - ruby-on-railsHow to match strings in a DB2 query (z / OS)? - db2All Articles