package main
import (
"database/sql"
"fmt"
"time"
"clickhouse-go"
)
const (
Host = "x.x.x.x"
Port = 9000
UserName = "xx"
Password = "xxx"
DBName = "xxx"
TBName = "xxx"
)
func main() {
// Open a connection to the ClickHouse database
conCK := fmt.Sprintf("tcp://%s:%d?username=%s&password=%s", Host, Port, UserName, Password)
conn, err := sql.Open("clickhouse", conCK)
if err != nil {
panic(err)
}
defer conn.Close()
// Prepare the ALTER statement
stmt, err := conn.Prepare("alter table xxx drop partition")
if err != nil {
panic(err)
}
defer stmt.Close()
// Execute the ALTER statement
_, err = stmt.Exec()
if err != nil {
panic(err)
}
fmt.Println("ALTER statement executed successfully")
}
GOLang操作CK
于 2023-04-08 14:51:31 首次发布