创建脚本以将数据插入数据库时失败了。我忘了在插入之前连接到我的数据库(我连接到postgres数据库,为了创建我的数据库),所以我的所有表现在都在postgres数据库中。
我怎么能删除所有这个表?可以按所有者删除表格吗?
提前致谢
答案 0 :(得分:1)
只要您确定要删除该用户拥有的所有对象,就可以使用DROP OWNED BY
。
否则你必须手工完成,这应该很简单,因为数据库postgres
通常是空的。
答案 1 :(得分:1)
如果架构中没有要保存的内容:
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
use Slim\Http\UploadedFile;
require '../vendor/autoload.php';
$app = new \Slim\App([
'settings' => [
'displayErrorDetails' => true
]
]);
$container = $app->getContainer();
$container['upload_directory'] ='../photos/';
$app->post('/photo', function (Request $request, Response $response) use ($app) {
$directory = $this->get('upload_directory');
$uploadedFiles = $request->getUploadedFiles();
$uploadedFile = $uploadedFiles['picture'];
if($uploadedFile->getError() === UPLOAD_ERR_OK) {
$filename = moveUploadedFile($directory, $uploadedFile);
$response->write('uploaded ' . $filename . '<br/>');
}
});
function moveUploadedFile($directory, UploadedFile $uploadedFile){
$extension = pathinfo($uploadedFile->getClientFilename(),
PATHINFO_EXTENSION);
$basename = bin2hex(random_bytes(8));
$filename = sprintf('%s.%0.8s', $basename, $extension);
$uploadedFile->moveTo($directory . DIRECTORY_SEPARATOR . $filename);
return $filename;
}
$app->run();
将drop schema public cascade;
create schema public;
grant all on schema public to public;
替换为架构名称(如果有)。