To clean the sql xdb database in Sitecore 9 you need to run bellow script in SQL on every shard that you have .
USE [yourdatabaseprefix.Collection.ShardX]
GO
DELETE FROM [xdb_collection].ContactIdentifiers
Delete from [xdb_collection].ContactFacets
Delete from [xdb_collection].InteractionFacets
Delete from [xdb_collection].Interactions
Delete from [xdb_collection].Contacts
Updated for 9.1
Add these also for 9.1
Delete from [xdb_collection].ContactIdentifiersIndex
Delete from [xdb_collection].DeviceProfileFacets
Delete from [xdb_collection].DeviceProfiles
Delete from [xdb_collection].DeviceProfileFacets
Delete from [xdb_collection].DeviceProfileFacets
You also need to clean the interactions out of the processing pool
TRUNCATE TABLE [xdb_processing_pools].[InteractionLiveProcessingPool]
If you use SOLR you need to update xdb solr index:
https://doc.sitecore.net/developers/xp/xconnect/xconnect-search-indexer/rebuild-index/rebuild-solr-index.html
For Azure Search you need to use:
https://doc.sitecore.net/developers/xp/xconnect/xconnect-search-indexer/rebuild-index/rebuild-azure-index.html
You should also to rebuild reporting database:
https://doc.sitecore.net/developers/xp/reporting/rebuild-reporting.html