Skip to content

ENH: DataFrame.to_sql with if_exists='replace' should do truncate table instead of drop table #37210

Closed
@tokorhon

Description

@tokorhon

Is your feature request related to a problem?

Dropping table when if_exists=‘replace’ will fail if the table has any objects, like a view, depending on it. Also, some databases like Oracle will end a transaction implicitly when a DLL statement like 'drop table' is issued.

Describe the solution you'd like

Better alternative would be to issue 'truncate table' command instead.

API breaking implications

Should not have any changes on API

Describe alternatives you've considered

As above or a new flag if_exists=‘truncate’

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementIO SQLto_sql, read_sql, read_sql_queryNeeds DiscussionRequires discussion from core team before further action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions